Android4.0平板开发之隐藏底部任务栏的方法
本文实例讲述了Android4.0平板开发之隐藏底部任务栏的方法。分享给大家供大家参考,具体如下:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);//隐藏底部任务栏代码
上边已验证
下边百度过来的
showBar显示任务栏
closeBar隐藏任务栏
前提:需要ROOT权限
publicstaticvoidshowBar(){ try{ Processproc=Runtime.getRuntime().exec( newString[]{"am","startservice","-n", "com.android.systemui/.SystemUIService"}); proc.waitFor(); }catch(Exceptione){ e.printStackTrace(); } } publicstaticvoidcloseBar(Contextcontext){ try{ //需要root权限 Build.VERSION_CODESvc=newBuild.VERSION_CODES(); Build.VERSIONvr=newBuild.VERSION(); StringProcID="79"; if(vr.SDK_INT>=vc.ICE_CREAM_SANDWICH){ ProcID="42";//ICSANDNEWER } //需要root权限 Processproc=Runtime.getRuntime().exec( newString[]{ "su", "-c", "servicecallactivity"+ProcID +"s16com.android.systemui"});//WAS79 proc.waitFor(); }catch(Exceptionex){ Toast.makeText(context,ex.getMessage(),Toast.LENGTH_LONG).show(); } }
1.ActionBar:
<activityandroid:name="Demo" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> <intent-filter> <actionandroid:name="android.intent.action.MAIN"/> <categoryandroid:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity>
2.TitleBar
隐藏:
requestWindowFeature(Window.FEATURE_NO_TITLE);
或者
android:theme="@android:style/Theme.Black.NoTitleBar
显示:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
3.NotificationBar、StatusBar、SystemBar
Dim的话可以:
getWindow().getDecorView().setSystemUiVisibility (View.SYSTEM_UI_FLAG_LOW_PROFILE);
隐藏的话可以(不好使,哈哈):
getWindow().getDecorView().setSystemUiVisibility (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
那怎么玩呢?用狠招吧,哈哈:
命令行方式:
直接用进程号杀,不加service那个shell的话,一会SystemBar会自启动。
#killcom.android.systemui #servicecallactivity79s16com.android.systemui
如果想启动SystemBar:
#amstartservice-ncom.android.systemui/.SystemUIService
代码方式:
要root啊
Processproc=Runtime.getRuntime().exec(newString[]{"su","-c","service callactivity79s16com.android.systemui"}); proc.waitFor(); Processproc=Runtime.getRuntime().exec(newString[]{"am","startservice","-n","com.android.systemui/.SystemUIService"}); proc.waitFor();
希望本文所述对大家Android程序设计有所帮助。