Android custom theme

I am new to Android and am a bit stuck in a theme app. I use the navigation box layout, so I need to use a backward compatible theme. My theme is as follows:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="android:actionBarStyle">@style/mycustomactionbar</item>
    </style>

    <style name="mycustomactionbar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">#6FBC2C</item>
        <item name="android:textColor">#FFFFFF</item>
    </style>

</resources>

However, when I run the code, the color of my action bar remains the same, but I get no errors. How could I debug such a thing? There is no error during assembly

+4
source share
1 answer

If you are using the current AppCompat library (version 21. +, with the Material theme), you can use the following code to recolor your theme.

. , .

<color name="primary">@color/material_brown_500</color>
<color name="primaryDark">@color/material_brown_700</color>
<color name="accent">@color/material_pink_A200</color>

<style name="My.Theme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primaryDark</item>
    <item name="colorAccent">@color/accent</item>
</style>


<color name="material_brown_500">#795548</color>
<color name="material_brown_700">#5D4037</color>
<color name="material_pink_A200">#FF4081</color>
+2

Source: https://habr.com/ru/post/1568662/


All Articles