美文网首页
android 设置状态栏颜色 透明

android 设置状态栏颜色 透明

作者: iOSDevLog | 来源:发表于2018-08-24 15:33 被阅读43次

    Lollipop:

    public abstract void setStatusBarColor (int color)
    

    Added in API level 21

    Window window = activity.getWindow();
    
    // clear FLAG_TRANSLUCENT_STATUS flag:
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    
    // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    
    // finally change the color
    window.setStatusBarColor(ContextCompat.getColor(activity,R.color.my_statusbar_color));
    

    https://stackoverflow.com/questions/22192291/how-to-change-the-status-bar-color-in-android

    相关文章

      网友评论

          本文标题:android 设置状态栏颜色 透明

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