Method 1
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 2
<! -- Hide the status bar and title bar at the same time --> <activity Android: Name = "com. ysj. demo. mainactivity "Android: theme =" @ Android: style/theme. notitlebar. fullscreen "Android: Label =" @ string/app_name "> <intent-filter> <action Android: Name =" android. intent. action. main "/> <category Android: Name =" android. intent. category. launcher "/> </intent-filter> </activity>
Method 3
<! -- Application theme. --> <style name = "apptheme" parent = "appbasetheme"> <! -- All mizmizations that are not specific to a special API-level can go here. --> <! -- Hide the status bar --> <item name = "Android: windowfullscreen"> true </item> <! -- Hide the title bar --> <item name = "Android: windownotitle"> true </item> </style>
Note:
1. The two sections of code in method 1 should be before setcontentview.
2. method 2 can only hide the status bar and title bar at the same time.
3. method 1 and method 2 are only applied to a single activity. Method 3 is applied to the entire program.
For tablets running Android 4.0 or above, the following three methods do not hide the status bar below the screen.
Public class startupactivity extends activity {@ overrideprotected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. activity_startup);/** hide the status bar */try {string procid = "79"; if (Android. OS. build. version. sdk_int> = android. OS. build. version_codes.ice_cream_sandwich) procid = "42"; // ICS // requires the root permission process proc = runtime.getruntime(cmd.exe C (New String [] {"Su", "-c ", "service call activity" + procid + "S16 COM. android. systemui "}); // was proc. waitfor ();} catch (exception ex) {toast. maketext (getapplicationcontext (), Ex. getmessage (), toast. length_long ). show () ;}@ overrideprotected void ondestroy () {// todo auto-generated method stub/** resume the status bar */try {process proc = runtime.getruntime(cmd.exe C (New String [] {"am ", "startservice", "-n", "com. android. systemui /. systemuiservice "}); Proc. waitfor ();} catch (exception e) {e. printstacktrace ();} super. ondestroy () ;}@ overridepublic Boolean oncreateoptionsmenu (menu) {// inflate the menu; this adds items to the action bar if it is present. 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 (); break;} return true ;}}
Because there is no status bar, you must provide the exit method in the program.