Search code examples
androidcustomizationandroid-5.0-lollipop

Android Customize EditText on Lollipop and Upper Version


On Android 5.0 and upper version EditText has a tint of the colorAccent from the AppTheme on it's background,cursor. But I want to not apply this colorAccent by custom. Like for example I declared my Theme style like below.

<style name="AppTheme" parent="Theme.AppCompat.Light">    
    <item name="colorPrimary">@color/color_primary</item>
    <item name="colorPrimaryDark">@color/color_primary_dark</item>
    <item name="android:textColorPrimary">@color/text_color_primary</item>
    <item name="android:textColorPrimaryInverse">@color/text_color_primary_inverse</item>
    <item name="colorAccent">@color/color_accent</item>
</style>

All I want is colorAccent would not applicable only for the EditText. Is there any way to do that?


Solution

  • Why dont you just define a new style

    <style name="AppTheme2" parent="Theme.AppCompat.Light">    
        <item name="colorPrimary">@color/color_primary</item>
        <item name="colorPrimaryDark">@color/color_primary_dark</item>
        <item name="android:textColorPrimary">@color/text_color_primary</item>
        <item name="android:textColorPrimaryInverse">@color/text_color_primary_inverse</item>
    </style>
    

    And then do:

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme2"/>