Status Bar Color not showing - 5.0 Lollipop Android Studio: (AppCompat-v7:r21)

前端 未结 11 1334
-上瘾入骨i
-上瘾入骨i 2020-12-23 20:02

I\'m using the AppCompat-v7:21.0.0 support library for Android 5.0 Lollipop in Android Studio. My problem is that the Status Bar Color that can be changed by se

相关标签:
11条回答
  • 2020-12-23 20:34

    In my case values-v21/styles.xml contained the following line which overrode the status bar color defined in values/style.xml with colorPrimaryDark:

    <item name="android:statusBarColor">@android:color/transparent</item>
    

    Removing this worked for me.

    0 讨论(0)
  • 2020-12-23 20:37

    test on my nexus7 5.1.1

    set in style.xml v21/v22 is not work

    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/holo_red_dark</item>
    

    but

    set in actvivity

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().setStatusBarColor(getResources().getColor(android.R.color.holo_red_dark));
    }
    

    is work for me

    0 讨论(0)
  • 2020-12-23 20:47

    This worked for me:

       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            getWindow().setStatusBarColor(getResources().getColor(R.color.some_color));
        }
    
    0 讨论(0)
  • 2020-12-23 20:47

    Did you set the target SDK version to 21? I had the same issue when I left the target SDK version to 19. You can leave the min SDK to anything lower.

    And of course you need to inherit from the proper theme and make sure your Activity uses it.

    0 讨论(0)
  • 2020-12-23 20:47

    Check if you are editing styles.xml in values-v21 folder. If you set SDK version to 21 then it won't look for styles.xml in values folder(but it should do so).

    enter image description here

    0 讨论(0)
提交回复
热议问题