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

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


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));    }


Please read this: For this to take effect, the window must be drawing the system bar backgrounds with

android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS

but

android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS

must not be set (Source)

In case of you don't know how to add that flag:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);


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.