系統狀態列和app頁面一體化

一年十二個月發表於2016-06-06
實現的步驟主要有以下幾點:
1.android4.4 以上版本
2.設定app全屏:
方法:在AndroidManifest.xml中設定android:theme="@android:style/Theme.Translucent.NoTitleBar"
3.載入nineoldandroids-2.4.0.jar
4.實現類:把狀態列背景設為全透明。
在setcontentview前面執行
 /**
     * 設定狀態列背景狀態
     */
    private void setTranslucentStatus() 
    {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
        {
            Window win = getWindow();
            WindowManager.LayoutParams winParams = win.getAttributes();
            final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
            winParams.flags |= bits;
            win.setAttributes(winParams);
        }
        SystemStatusManager tintManager = new SystemStatusManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintResource(0);//狀態列無背景
    }

相關文章