Android: how to change bottom line color in EditText for API 19

I am having trouble changing the color of the bottom line of an EditText. I tried:

 <style name="MyEditTextTheme">
    <item name="android:colorControlNormal">#F0DDAA</item>
</style>

      

but apparently it only works with API 22 of my emulator, when I tried to downgrade to API 19 it has no effect. Appreciate your help.

+3


source to share


1 answer


To support older versions use this style, the parent must be @style/Widget.AppCompat.EditText

<style name="MyEditTextTheme" parent="@style/Widget.AppCompat.EditText">
    <item name="colorControlNormal">#FF0000</item>
</style>

//your edit text  
<EditText 
    ....
    android:theme="@style/MyEditTextTheme" />

      



IMPT : your class must extend , otherwise the theme won't work. AppCompatActivity

+2


source







All Articles