Android fullscreen (includes 3 hidden top status bars and a title bar and a way to hide the Android 4.0 tablet bottom status bar)

Source: Internet
Author: User

Http://www.xuebuyuan.com/558284.html

Method One

public class Mainactivity extends activity{@Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);//Hide the title bar requestwindowfeature (window.feature_no_title);//Hide the status bar GetWindow (). SetFlags ( Windowmanager.layoutparams.flag_fullscreen,windowmanager.layoutparams.flag_fullscreen); SetContentView ( R.layout.activity_main);}}

Method Two

<!--hide the status bar and title bar--><activity android:name= "com.ysj.demo.MainActivity" Android:theme= "@android: Style/them E.notitlebar.fullscreen "android:label=" @string/app_name "> <intent-filter> <action android:name= "Android.intent.action.MAIN"/> <category android:name= "Android.intent.category.LAUNCHER"/> </inten T-filter></activity>

Method Three

<!--application theme. --><style name= "Apptheme" parent= "Appbasetheme" >    <!--All customizations that is not specific to a parti Cular Api-level can go here. -    <!--hide the status bar-    <item name= "Android:windowfullscreen" >true</item>    <!-- Hide title bar--    <item name= "Android:windownotitle" >true</item></style>

Note:

1. The two-segment code in method one should precede setcontentview ().

2, method Two can only hide the status bar and the title bar at the same time.

3, method One and method two are applied only to a single activity. Method three applies to the whole program.

For tablets running Android 4.0 or above, the above three methods do not hide the status bar below the screen and must be treated as follows.

 Public classStartupactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_startup); /** Hide the status bar under the screen of the tablet running Android 4.xxx system requires root permission*/Closebar (); } @Overrideprotected voidOnDestroy () {Showbar (); Super. OnDestroy (); }    /*** Close the Android navigation bar for full screen*/Private voidClosebar () {Try{String command; Command= "Ld_library_path=/vendor/lib:/system/lib Service call activity s16 Com.android.systemui"; ArrayList<String> envlist =NewArraylist<string>(); Map<string, string> env =system.getenv ();  for(String envName:env.keySet ()) {Envlist.add (Envname+ "=" +Env.get (envname)); } string[] ENVP= Envlist.toarray (NewString[0]); Process proc=runtime.getruntime (). EXEC (NewString[] {"Su", "-C", command}, ENVP);        Proc.waitfor (); } Catch(Exception ex) {//Toast.maketext (Getapplicationcontext (), Ex.getmessage (),//Toast.length_long). Show ();        }    }    /*** Show navigation bar*/ Public Static voidShowbar () {Try{String command; Command= "Ld_library_path=/vendor/lib:/system/lib am startservice-n com.android.systemui/. Systemuiservice "; ArrayList<String> envlist =NewArraylist<string>(); Map<string, string> env =system.getenv ();  for(String envName:env.keySet ()) {Envlist.add (Envname+ "=" +Env.get (envname)); } string[] ENVP= Envlist.toarray (NewString[0]); Process proc=runtime.getruntime (). EXEC (NewString[] {"Su", "-C", command}, ENVP);        Proc.waitfor (); } Catch(Exception e) {e.printstacktrace (); }    }}

Since the status bar is not available, you must provide a method for exiting the program in the program.


Source: http://www.cnblogs.com/tc310/p/4024686.html

From for notes (Wiz)

Android fullscreen (includes 3 hidden top status bars and a title bar and a way to hide the Android 4.0 tablet bottom status bar)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.