I'm not sure I understand the problem.
I you want to change the status bar color programmatically (and provided the device has Android 5.0) then you can use Window.setStatusBarColor()
. It shouldn't make a difference whether the activity is derived from Activity
or ActionBarActivity
.
Just try doing:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.BLUE);
}
Just tested this with ActionBarActivity
and it works alright.
Note: Setting the FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
flag programmatically is not necessary if your values-v21
styles file has it set already, via:
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…