Windows

  • 取色器
    ColorPix

  • 自定义对话框报异常:The specified child already has a parent. You must call removeView()
    AlertDialog.Builder(mContext).setView(view)中,子视图是view,父视图是Builder,按下面文章所说的,原因就是:一个子视图指定了多个父视图。由此可以推断出,在第二次点击按钮弹出对话框时,子视图与第一次点击时的子视图是同一个对象,而父视图已经不再是同一个对象了。Android使用自定义对话框报错:The specified child already has a parent. You must call removeView() on the...
    解决办法:

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)