0

I use the new Toolbar with a Contextual Action Bar. When I used the appcompat-v7:22.0.0 library, everything works fine when selecting a list item. But after updating to 22.1.1 and refactoring my ActionBarActivity to the new AppCompatActivity, the CAB does not keep its colors on devices with API < 21.

With appcompat v7:22.0.0 it looked like this (and on API 21, it still does):

CAB before

With appcompat v7:22.1.1 and API 19, it looks like this (smaller size is ok because of different device size):

CAB with new appcompat

My toolbar.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:theme="@style/ToolBarStyle"/>

and this is my themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="windowActionModeOverlay">true</item>
    </style>

    <style name="AppTheme" parent="AppTheme.Base"/>

    <!-- ToolBar -->
    <style name="ToolBarStyle" parent="Theme.AppCompat">
        <item name="android:background">@color/hero_blue</item>
        <item name="android:textColorPrimary">@android:color/white</item>
        <item name="android:textColorSecondary">@android:color/white</item>
        <item name="actionMenuTextColor">@android:color/white</item>
        <item name="actionModeBackground">@color/hero_blue</item>
        <item name="android:textSize">12sp</item>

    </style>
</resources>
KCD
  • 678
  • 5
  • 20
  • you need to remove all `android:` references when using app compat – tyczj Jun 01 '15 at 16:40
  • also you need to use `colorPrimary` to set the background of your toolbar and not background – tyczj Jun 01 '15 at 16:41
  • tyczj, what do you mean with removing all android:references? When I use colorPrimary, nothing changed, when I use android:colorPrimary, it says "colorPrimary requires api leve 21, min is 15". – KCD Jun 01 '15 at 16:49
  • you need to do this `@color/hero_blue` notice there is no `android:colorPrimary` – tyczj Jun 01 '15 at 16:50
  • This is not working :( – KCD Jun 03 '15 at 11:52

0 Answers0