簡體   English   中英

是否可以在Android M上鎖定狀態欄和導航欄

[英]Is it possible to lock status bar and navigation bar on Android M

在我的項目中,我需要鎖定狀態欄和導航欄,以避免最終用戶進入原始啟動器,並且在API 21中,我嘗試使用startLocktask()方法,兩個bar功能都可以禁用,但是我不能調用第三個派對APK,那么,如果有機會鎖定兩個酒吧,但仍然可以啟動第三方APK?

我很早以前就發現了這種用法,也許也對您有用:

public class MainActivity extends AppCompatActivity {


@Override
protected void onCreate (Bundle savedInstanceState) {

    super.onCreate (savedInstanceState);

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

    // Hide the Status Bar
    getWindow ().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);


    setContentView (R.layout.main_layout);

}

@Override
protected void onResume () {
    //Log.d (TAG, "onResume");
    super.onResume ();

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

    // Hide the Status Bar
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

}

}

當屏幕旋轉時要當心,也應該牢記它。

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM