Windows

作者: ncd | 来源:发表于2017-01-20 10:52 被阅读11次
ViewGroup parent = (ViewGroup) view.getParent();
 if (parent != null) {
    parent.removeAllViews();
 } 

然后再给AlertDialog指定view。

  • 沉浸式状态栏
    首先给Activity根布局设置属性:android:fitsSystemWindows="true"
    然后调用下面的方法:
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

相关文章

网友评论

      本文标题:Windows

      本文链接:https://www.haomeiwen.com/subject/hiuwbttx.html