您的位置:首页 > 其它

简单实现沉浸式状态栏

2017-09-18 11:26 148 查看
public static void MyWi(Activity activity){

        Window window = activity.getWindow();

//        对SDK版本进行判断,大于19执行此代码

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

            //透明状态栏

            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

            //透明导航栏

            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

            SystemBarTintManager tintManager = new SystemBarTintManager(activity);

            // 激活状态栏

            tintManager.setStatusBarTintEnabled(true);

            // enable navigation bar tint 激活导航栏

            tintManager.setNavigationBarTintEnabled(true);

            //设置系统栏设置颜色

            //tintManager.setTintColor(R.color.red);

            //给状态栏设置颜色

            tintManager.setStatusBarTintResource(R.color.umeng_comm_green);//在colors里添加自定义颜色

            //Apply the specified drawable or color resource to the system navigation bar.

            //给导航栏设置资源

            tintManager.setNavigationBarTintResource(R.color.umeng_comm_green);

        }

    }

更多0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: