Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android4.0平板開發之隱藏底部任務欄的方法

Android4.0平板開發之隱藏底部任務欄的方法

編輯:關於Android編程

本文實例講述了Android4.0平板開發之隱藏底部任務欄的方法。分享給大家供大家參考,具體如下:
復制代碼 代碼如下:getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);//隱藏底部任務欄代碼
上邊已驗證

下邊百度過來的

showBar顯示任務欄

closeBar隱藏任務欄

前提:需要ROOT權限

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:

<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的話可以:

getWindow().getDecorView().setSystemUiVisibility
 (View.SYSTEM_UI_FLAG_LOW_PROFILE); 

隱藏的話可以(不好使,哈哈):

getWindow().getDecorView().setSystemUiVisibility
 (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

那怎麼玩呢?用狠招吧,哈哈:

命令行方式:

直接用進程號殺,不加service那個shell的話,一會SystemBar會自啟動。

# kill com.android.systemui
# service call activity 79 s16 com.android.systemui

如果想啟動SystemBar:
復制代碼 代碼如下:# am startservice -n com.android.systemui/.SystemUIService

代碼方式:

要root啊

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程序設計有所幫助。

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved