• Android沉浸式状态栏


    private void initWindows() {
            Window window = getWindow();
            int color = getResources().getColor(android.R.color.holo_blue_light);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                //设置状态栏颜色
                window.setStatusBarColor(color);
                //设置导航栏颜色
                window.setNavigationBarColor(color);
                ViewGroup contentView = ((ViewGroup) findViewById(android.R.id.content));
                View childAt = contentView.getChildAt(0);
                if (childAt != null) {
                    childAt.setFitsSystemWindows(true);
                }
            } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                //透明状态栏
                window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                //透明导航栏
                window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                //设置contentview为fitsSystemWindows
                ViewGroup contentView = (ViewGroup) findViewById(android.R.id.content);
                View childAt = contentView.getChildAt(0);
                if (childAt != null) {
                    childAt.setFitsSystemWindows(true);
                }
                //给statusbar着色
                View view = new View(this);
                view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(this)));
                view.setBackgroundColor(color);
                contentView.addView(view);
            }
        }
    复制代码http://www.cnblogs.com/whoislcj/p/6250284.html
    https://github.com/gyf-dev/ImmersionBar
    https://github.com/jgilfelt/SystemBarTint/tree/master/sample/src/com
  • 相关阅读:
    启动matlab时总是直接跳转到安装界面的解决方案
    毕业倒计时
    PARAMETER和ARGUMENT的区别
    在Windows上使用Ubuntu共享的打印机
    Ubuntu 16.04 + CUDA 8.0 + cuDNN v5.1 + TensorFlow(GPU support)安装配置详解
    深度学习硬件购买指南
    GeForce GTX 1080 ti安装记录
    What is a TensorFlow Session?
    来来来,干了这碗毒鸡汤……
    [译] 理解 LSTM(Long Short-Term Memory, LSTM) 网络
  • 原文地址:https://www.cnblogs.com/wcLT/p/8513993.html
Copyright © 2020-2023  润新知