The full screen display here refers to removing the Activity title bar and the system status bar. To sum up, there are three methods to achieve this, but some points are worth noting. The following describes each method and its problems.
Method 1: Programming
Add the following code to the Java program:
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Pay attention to the following two issues:
1. Add time: set the time before the setcontentview () function is called on the activity interface to be displayed in full screen; otherwise, the following error is reported:
E/AndroidRuntime( 479): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)E/AndroidRuntime( 479): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)E/AndroidRuntime( 479): at android.app.ActivityThread.access$1500(ActivityThread.java:117)E/AndroidRuntime( 479): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)E/AndroidRuntime( 479): at android.os.Handler.dispatchMessage(Handler.java:99)E/AndroidRuntime( 479): at android.os.Looper.loop(Looper.java:123)E/AndroidRuntime( 479): at android.app.ActivityThread.main(ActivityThread.java:3683)E/AndroidRuntime( 479): at java.lang.reflect.Method.invokeNative(Native Method)E/AndroidRuntime( 479): at java.lang.reflect.Method.invoke(Method.java:507)E/AndroidRuntime( 479): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)E/AndroidRuntime( 479): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)E/AndroidRuntime( 479): at dalvik.system.NativeStart.main(Native Method)E/AndroidRuntime( 479): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding contentE/AndroidRuntime( 479): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:181)E/AndroidRuntime( 479): at android.app.Activity.requestWindowFeature(Activity.java:2729)E/AndroidRuntime( 479): at XXXActivity.onCreate(IHomeActivity.java:16)E/AndroidRuntime( 479): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)E/AndroidRuntime( 479): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)E/AndroidRuntime( 479): ... 11 more
2. There is a problem: This method can achieve full screen display, but the title bar of the activity will stay for a short time and it looks uncomfortable.
Method 2: Configure using an XML file
In androidmanifest. XML, add the following theme for the activity that requires full screen display:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
This method is perfect, simple, and there is no one in the method. We recommend that you use it!
Method 3: Combination boxing, encoding and xml configuration
This method is improved based on method 1. The specific method is:
1) Add code to Java according to method 1
2) In androidmanifest. XML, add the following theme for the activity that requires full screen display:
android:theme="@android:style/Theme.NoTitleBar"
This method achieves the same I effect as method 2. In essence, it is implemented by adding corresponding configurations to the XML file to eliminate problem 2 in method 1.