124697
124697

Reputation: 21893

Style is ignored and everything is gray in Lollipop

I am trying to change the style of the app but everything is grey instead. What's the problem?

I am using android studio. This project was originally on eclipse. I am not building it using Lollipop on Android Studio

<application
        android:name=".MainApplication"
        tools:replace="android:icon,android:theme"
        android:label="@string/app_name"
        android:logo="@drawable/ic_logo"
        android:theme="@style/Theme.Materialred" >

styles_materialred.xml:

<resources>

    <style name="Theme.Materialred" parent="@style/Theme.AppCompat.Light">
        <item name="actionBarItemBackground">@drawable/selectable_background_materialred</item>
        <item name="popupMenuStyle">@style/PopupMenu.Materialred</item>
        <item name="dropDownListViewStyle">@style/DropDownListView.Materialred</item>
        <item name="actionBarTabStyle">@style/ActionBarTabStyle.Materialred</item>
        <item name="actionDropDownStyle">@style/DropDownNav.Materialred</item>
        <item name="actionBarStyle">@style/ActionBar.Solid.Materialred</item>
        <item name="actionModeBackground">@drawable/cab_background_top_materialred</item>
        <item name="actionModeSplitBackground">@drawable/cab_background_bottom_materialred</item>
        <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Materialred</item>


    </style>

    <style name="ActionBar.Solid.Materialred" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
        <item name="background">@drawable/ab_solid_materialred</item>
        <item name="backgroundStacked">@drawable/ab_stacked_solid_materialred</item>
        <item name="backgroundSplit">@drawable/ab_bottom_solid_materialred</item>
        <item name="progressBarStyle">@style/ProgressBar.Materialred</item>
    </style>

    <style name="ActionBar.Transparent.Materialred" parent="@style/Widget.AppCompat.Light.ActionBar">
        <item name="background">@drawable/ab_transparent_materialred</item>
        <item name="progressBarStyle">@style/ProgressBar.Materialred</item>
    </style>

    <style name="PopupMenu.Materialred" parent="@style/Widget.AppCompat.Light.PopupMenu">   
        <item name="android:popupBackground">@drawable/menu_dropdown_panel_materialred</item>   
    </style>

    <style name="DropDownListView.Materialred" parent="@style/Widget.AppCompat.Light.ListView.DropDown">
        <item name="android:listSelector">@drawable/selectable_background_materialred</item>
    </style>

    <style name="ActionBarTabStyle.Materialred" parent="@style/Widget.AppCompat.Light.ActionBar.TabView">
        <item name="android:background">@drawable/tab_indicator_ab_materialred</item>
    </style>

    <style name="DropDownNav.Materialred" parent="@style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
        <item name="android:background">@drawable/spinner_background_ab_materialred</item>
        <item name="android:popupBackground">@drawable/menu_dropdown_panel_materialred</item>
        <item name="android:dropDownSelector">@drawable/selectable_background_materialred</item>
    </style>

    <style name="ProgressBar.Materialred" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
        <item name="android:progressDrawable">@drawable/progress_horizontal_materialred</item>
    </style>

    <style name="ActionButton.CloseMode.Materialred" parent="@style/Widget.AppCompat.Light.ActionButton.CloseMode">
        <item name="android:background">@drawable/btn_cab_done_materialred</item>
    </style>

    <!-- this style is only referenced in a Light.DarkActionBar based theme -->
    <style name="Theme.Materialred.Widget" parent="@style/Theme.AppCompat">
        <item name="popupMenuStyle">@style/PopupMenu.Materialred</item>
        <item name="dropDownListViewStyle">@style/DropDownListView.Materialred</item>
    </style>

Upvotes: 4

Views: 1379

Answers (3)

JavierSegoviaCordoba
JavierSegoviaCordoba

Reputation: 6631

You have to use this:

   <style name="AppThemeRandom" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->

    <!-- The primary branding color for the app. By default, this is the color applied to the
     action bar background. -->
    <item name="colorPrimary">@color/md_indigo_500</item>
    <!-- Dark variant of the primary branding color. By default, this is the color applied to
     the status bar (via statusBarColor) and navigation bar (via navigationBarColor). -->
    <item name="colorPrimaryDark">@color/md_indigo_700</item>
    <!-- Bright complement to the primary branding color. By default, this is the color applied
     to framework controls (via colorControlActivated). -->
    <item name="colorAccent">@color/md_pink_A200</item>
    <!-- The color applied to framework controls in their normal state. -->
    <item name="colorControlNormal">@color/md_amber_500</item>
    <!-- The color applied to framework controls in their activated (ex. checked) state. -->
    <item name="colorControlActivated">@color/md_green_500</item>
    <!-- The color applied to framework control highlights (ex. ripples, list selectors). -->
    <item name="colorControlHighlight">@color/md_teal_500</item>
    <!-- The color applied to framework buttons in their normal state. -->
    <item name="colorButtonNormal">@color/md_red_500</item>
    <!-- The color applied to framework switch thumbs in their normal state. -->
    <item name="colorSwitchThumbNormal">@color/md_black_1000_50</item>
    <!-- Inactive track color(75% transparency) -->
    <item name="android:colorForeground">@color/md_black_1000_75</item>
</style>

Obviously, choose your colors, it is a random theme to check all colors in status bar, toolbar, widgets like checkbox, etc.

Upvotes: 0

Josh
Josh

Reputation: 21

I was having this problem and just noticed that there was a separate styles.xml file for Lollipop. It was originally hidden by the default file, but clicking the arrow reveals it. Editing this one works as expected.

tree showing res->values->styles.xml->styles.xml

Upvotes: 1

N Sharma
N Sharma

Reputation: 34497

Set the color in this way in action bar theme.

<item name="colorPrimary">@color/primaryDef</item>

Read this interesting article of Chris Banes https://chris.banes.me/2014/10/17/appcompat-v21/#migrationfromprevioussetup

Upvotes: 1

Related Questions