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 class Startupactivity extends activity{@Overrideprotected void OnCreate (Bundle savedinstancestate) { Super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_startup); * * Hide the status bar below the screen of a tablet running Android 4.0 or above system          */try {String procid = "79"; if (Android.os.Build.VERSION.SDK_INT >= Android.os.Build.VERSION_CODES. Ice_cream_sandwich) ProcID = "42"; ICS//requires root privileges Process proc = Runtime.getruntime (). EXEC (new string[] {"Su", "-C", "Service call AC Tivity "+ procid +" S16 Com.android.systemui "});      was Proc.waitfor (); } catch (Exception ex) {Toast.maketext (Getapplicationcontext (), Ex.getmessage (), toast.length_long). Sh      ow ();      }} @Overrideprotected void OnDestroy () {//TODO auto-generated Method stub/* * Restores the status bar below the screen of the tablet that runs Android 4.0 above the system */try {Process proc = runtime.getruntime (). EXEC (new string[] {"AM", "StartService", "-N", "com.android.systemui/".          Systemuiservice "}); Proc. WaitFor ();      } catch (Exception e) {e.printstacktrace (); } Super.ondestroy ();} @Overridepublic boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu; This adds items to the action Bar if it is pre Sent.getmenuinflater (). Inflate (R.menu.startup, menu); return true;} @Overridepublic boolean onoptionsitemselected (MenuItem Item) {//TODO auto-generated method Stubswitch (Item.getitemid ( ) {case r.id.action_exit:finish (); return true;}}

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

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.