Summary of common Activity features in Android of includes full screen horizontal and vertical screen etc
- 2020-09-28 09:09:10
- OfStack
This article illustrates the summary of common Activity features in Android (including full screen, vertical screen, etc.). To share for your reference, the details are as follows:
Activity full screen Settings
Method 1: AndroidManifest.xml
<activity android:name="myAcitivty" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
Approach 2: Code implementation
requestWindowFeature(Window.FEATURE_NO_TITLE); // Hide title bar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); // Hidden status bar
Note: The two sections of code used to set the full screen must precede setContentView(R.layout.main), otherwise an error will be reported.
Activity horizontal and vertical Settings
Method 1: ES25en. xml
<activity android:name="myAcitivty" android:screenOrientation="landscape" /> // or " portrait "
Approach 2: Code implementation
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Gets the landscape direction
int orientation = this.getResources().getConfiguration().orientation;
Common values for orientation can be ES37en.SCREEN_ES39en_ES40en (landscape) or ActivityInfo.SCREEN_ES43en_ES44en (portrait)
Activity screen 1 straight display
1: AndroidManifest.xml add permissions
<uses-permission android:name="android.permission.WAKE_LOCK" />
2: Code implementation
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
I hope this article has been helpful for Android programming.