Customizing themes for Android API 9 and 10

1

I have an App that runs from API 9 to 23 of Android, however the text colors are different from the colors set, the correct Blue Toolbar with white text. The problem occurs only in APIs 9 and 10.

Andthestyleisasfollows:

<!--Baseapplicationtheme.--><stylename="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="ThemeAccent" parent="AppTheme">
    <item name="colorAccent">@color/colorPrimary</item>
</style>

Any solutions to this problem?

Thank you in advance!

    
asked by anonymous 05.01.2016 / 13:08

1 answer

1

I advise using a Toobar, because it is much more practical and easy. In your layouts, place:

  <android.support.v7.widget.Toolbar
        android:id="@+id/toobar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        app:theme="@style/toobarStyle"
        android:elevation="3dp"
        />

In your style place:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>     
</style>
<style name="toobarStyle" parent="Theme.AppCompat">
    <item name="popupTheme">@style/Theme.AppCompat.Light</item>
    <item name="colorControlNormal">@color/colorAccent</item>
</style>

In the color file use:

<resources>
  <color name="colorPrimary">sua cor</color>
  <color name="colorPrimaryDark">sua cor</color>
  <color name="colorAccent">#fff</color>
</resources>

In the onCreate of your activitys put:

    Toolbar toobar = (Toolbar)findViewById(R.id.toolbar);
    setSupportActionBar(toobar);
    
05.01.2016 / 20:25