Windows

2017-01-20  本文已影响11人  ncd
ViewGroup parent = (ViewGroup) view.getParent();
 if (parent != null) {
    parent.removeAllViews();
 } 

然后再给AlertDialog指定view。

protected void setTranslucentStatus(int color) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            setTranslucentStatus(true);
        }
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintResource(color);// 通知栏所需颜色
    }

    @TargetApi(19)
    private void setTranslucentStatus(boolean on) {
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);
    }

其中类SystemBarTintManager请看项目https://github.com/jgilfelt/SystemBarTint

上一篇 下一篇

猜你喜欢

热点阅读