I'm developing an simple app to test the material design. I'm using com.android.support:appcompat-v7:21.0.0
and my activity looks like:
public class MyActivity extends ActionBarActivity {
...
}
The layout is defined as:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="128dp"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimaryDark"/>
</LinearLayout>
Now i defined my theme following material guidelines:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/colorPrimary500</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark700</item>
</style>
I'd like to change the status bar color in pre Android 5 and set it to colorPrimaryDark
but i can't find the way. I tried using:
getWindow().setStatusBarColor(..)
but setStatusBar color is available from level 21.
Why if i define a colorPrimaryDark
in my theme and use appcompact the status bar doesn't change color?
Anyone can help?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…