williamj949
williamj949

Reputation: 11316

How to Set primary/accent colors for widgets for entire application?

My base theme file for application is following wherein i am setting the primary colors and the accent colors

    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <item name="colorPrimary">@color/primary_yellow</item>
        <item name="colorPrimaryDark">@color/primary_yellow_dark</item>
        <item name="colorAccent">@color/accent</item>
        <item name="colorButtonNormal">@color/primary_orange</item>
</style>

However when i am using the editext and switches as well as the radio buttons i am getting the stock blue color for the widgets when it is pressed or when it's state has changed.All i want is to change to the primary color which is set in my styles.xml.Also as i am targeting devices greater than API16,i want uniform support across all devices upto API22

Any help would be appreciated!

EDIT

Using the themes for entire aplication like this

<application
        android:allowBackup="true"
        android:icon="@drawable/launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        tools:replace="android:theme,android:icon">

Upvotes: 3

Views: 525

Answers (1)

williamj949
williamj949

Reputation: 11316

Found the solution i created two styles.xml files one for API21 and above and one for API16 and above.In that added added these two lines to the base theme

<!--used for changing the focius colors of editext-->
 <item name="colorControlActivated">@color/primary_yellow</item>
 <item name="colorControlHighlight">@color/primary_yellow</item>

Upvotes: 1

Related Questions