Cant Set Android Actionbar Background Correctly
The Problem When im setting the ActionBar Background Color the Bar looks like this: i cant upload Images here so here is the File: Android ActionBar Problem My values/styles File &
Solution 1:
getSupportActionBar().setBackgroundDrawable(draw);
should be, in your case
getSupportActionBar().setBackgroundDrawable(getResources.getDrawable(R.drawable.your_drawable_name);
The Constructor of ColorDrawable takes the int that represent the color, not the id of the color. Use instenad
ColorDrawable draw = new ColorDrawable(getResources().getColor(R.color.grey));
Edit:
about the style.xml, you need both the item with and without the android prefix:
<!-- Application theme. --><stylename="AppTheme"parent="AppBaseTheme"><itemname="android:actionBarStyle">@style/ActionBarTheme</item><itemname="actionBarStyle">@style/ActionBarTheme</item></style>Lint is probably going to complain about it, because of the minSDK value. if it does you can add tools:ignore="NewApi" to the item with the android: prefix. For instance:
<itemname="android:actionBarStyle"tools:ignore="NewApi">@style/ActionBarTheme</item>
Post a Comment for "Cant Set Android Actionbar Background Correctly"