本文实例讲述了Android4.0平板开发之隐藏底部任务栏的方法。分享给大家供大家参考,具体如下:
复制代码 代码如下:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);//隐藏底部任务栏代码
上边已验证
下边百度过来的
showBar显示任务栏
closeBar隐藏任务栏
前提:需要ROOT权限
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
public static void showBar() {
try {
Process proc = Runtime.getRuntime().exec(
new String[] { "am" , "startservice" , "-n" ,
"com.android.systemui/.SystemUIService" });
proc.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void closeBar(Context context) {
try {
// 需要root 权限
Build.VERSION_CODES vc = new Build.VERSION_CODES();
Build.VERSION vr = new Build.VERSION();
String ProcID = "79" ;
if (vr.SDK_INT >= vc.ICE_CREAM_SANDWICH) {
ProcID = "42" ; // ICS AND NEWER
}
// 需要root 权限
Process proc = Runtime.getRuntime().exec(
new String[] {
"su" ,
"-c" ,
"service call activity " + ProcID
+ " s16 com.android.systemui" }); // WAS 79
proc.waitFor();
} catch (Exception ex) {
Toast.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();
}
}
|
1.ActionBar:
1
2
3
4
5
6
7
8
|
< activity android:name = "Demo"
android:label = "@string/app_name"
android:theme = "@android:style/Theme.NoTitleBar.Fullscreen" >
< intent-filter >
< action android:name = "android.intent.action.MAIN" />
< category android: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的话可以:
1
2
|
getWindow().getDecorView().setSystemUiVisibility
(View.SYSTEM_UI_FLAG_LOW_PROFILE);
|
隐藏的话可以(不好使,哈哈):
1
2
|
getWindow().getDecorView().setSystemUiVisibility
(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
|
那怎么玩呢?用狠招吧,哈哈:
命令行方式:
直接用进程号杀,不加service那个shell的话,一会SystemBar会自启动。
1
2
|
# kill com.android.systemui
# service call activity 79 s16 com.android.systemui
|
如果想启动SystemBar:
复制代码 代码如下:
# am startservice -n com.android.systemui/.SystemUIService
代码方式:
要root啊
1
2
3
4
5
|
Process proc = Runtime.getRuntime().exec( new String[]{ "su" , "-c" ,"service
call activity 79 s16 com.android.systemui"});
proc.waitFor();
Process proc = Runtime.getRuntime().exec( new String[]{ "am" , "startservice" , "-n" , "com.android.systemui/.SystemUIService" });
proc.waitFor();
|
希望本文所述对大家Android程序设计有所帮助。