Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (10.2k points)

I am using appcompat v7 to get the look consistent on Android 5 and less. It works rather well. However I cannot figure out how to change the bottom line color and the accent color for EditTexts. Is it possible?

I have tried to define a custom android:editTextStyle (cf. below) but I only succeeded to change the full background color or text color but not the bottom line nor the accent color. Is there a specific property value to use? do I have to use a custom drawable image through the android:background property? is it not possible to specify a color in hexa?

 <style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">

     <item name="android:editTextStyle">@style/Widget.App.EditText</item>

 </style>

 <style name="Widget.App.EditText" parent="Widget.AppCompat.EditText">

     ???

 </style>

According to android API 21 sources, EditTexts with material design seem to use colorControlActivated and colorControlNormal. Therefore, I have tried to override these properties in the previous style definition but it has no effect. Probably appcompat does not use it. Unfortunately, I cannot find the sources for the last version of appcompat with material design.

1 Answer

0 votes
by (46k points)

Finally, I have found a solution. It simply consists of overriding the value for colorControlActivated, colorControlHighlight and colorControlNormal in your app description definition and not your edit text form. Then, think to practice this theme for whatever activity you desire. Below is an instance:

<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">

    <item name="colorControlNormal">#c5c5c5</item>

    <item name="colorControlActivated">@color/accent</item>

    <item name="colorControlHighlight">@color/accent</item>

</style>

Related questions

0 votes
2 answers
0 votes
1 answer
asked Nov 25, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Nov 20, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Oct 13, 2019 in Java by Ritik (3.5k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...