不同版本设置侵入式标题

来源:互联网 发布:卖金蝶软件 编辑:程序博客网 时间:2024/06/13 13:29
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {            getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);        }        if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {            View v = findViewById(R.id.root_layout);            if (v != null) {                v.setFitsSystemWindows(true);            }        }        if(VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {             Window window = getWindow();              window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);              window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN                              | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);              window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);              window.setStatusBarColor(Color.TRANSPARENT);        } 

R.id.root_layout,是主界面的根id

@Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        mContext = this;        mActivity = this;        requestWindowFeature(Window.FEATURE_NO_TITLE); // 隐藏标题栏    }
原创粉丝点击