0

Update

Even when using minSdkVersion 21, if I use colorControl, it changes the color of the underline but not of the text "Email". Any idea how to change the color of the text "Email"?

This is my app:

enter image description here

Currently, when I click into the email field, the underline and the text "Email" is the turquoise color. I know how to change the color of the underline when it is not clicked, but how do I change the color of the underline when it is focussed / clicked on?

My minSdkVersion is 15, so colorControl does not work and backgroundTint does not get the job done either. Is there a way to accomplish what I want with version 15 and up?

Also, I am using <AutoCompleteTextView> and not <EditText> for the email address field (it was actually what android studio uses by default when creating a "Login Activity").

SilentDev
  • 20,997
  • 28
  • 111
  • 214
  • https://stackoverflow.com/a/35743390/4168607 – ADM May 07 '18 at 17:15
  • @ADM Unfortunately `colorControl` does not work for me as my `minSdkVersion` is 15 and `colorControl` only works for version 21 and up (I tried using it before but android studio gave a red underline under the code and when I hovered over it it mentioned that version 21 is needed). Is there a way to do it with version 15 and up? – SilentDev May 07 '18 at 17:18
  • Did you tried like https://stackoverflow.com/questions/34592451/change-size-of-edittext-bottom-border/34609916#34609916 – Srikanth May 07 '18 at 17:52
  • @ADM I changed my sdkVersion to 21 and although colorControlNormal and colorControlActivated changes the color of the underline to white even when clicked, it does not change the name of the word "Email". Is there a way to change the name of the word "Email" as well which appears at the top of the TextBox? – SilentDev May 07 '18 at 18:00
  • I am not sure of the widget you are using Try https://stackoverflow.com/a/30914037/4168607. Add xml part in question. – ADM May 07 '18 at 18:11
  • @ADM unfortunately the solutions in the link provided does not work from what I tried. The color changes when I change the theme, so it is changeable, I just don't know what to change specifically. The widgets I used are basically whatever default was created when creating a default "Login Activity" in Android Studio. It should be easy to replicate on your end, if it's possible. – SilentDev May 07 '18 at 18:29

1 Answers1

2

Just add app:backgroundTint="@color/your_color" in your AppCompatEditText in XML.

EDIT

Alright, you need to add style in styles.xml

<style name="nameOfStyle"> <item name="colorControlNormal">@color/your_color_without_focus</item> <item name="colorControlActivated">@color/your_color_when_focus</item> </style>

and then add this style to your AutoCompleteTextView with android:theme="@style/nameOfStyle"

Igor Staszewski
  • 401
  • 2
  • 8
  • Sorry. I forgot to mention that I am not using `EditText`, I am using `` (it was actually what android studio uses by default when creating a "Login Activity". Is there a way to do it with ``? I tried `backgroundTint` for the `` and it unfortunately does not work. – SilentDev May 07 '18 at 17:21
  • I changed my answer. – Igor Staszewski May 07 '18 at 17:26
  • @IgorStaszewki Hi, unfortunately `colorControl` does not work for me as my `minSdkVersion` is 15 and `colorControl` only works for version 21 and up (I tried using it before but android studio gave a red underline under the code and when I hovered over it it mentioned that version 21 is needed). Is there a way to do it with version 15 and up? – SilentDev May 07 '18 at 17:30
  • I changed my sdkVersion to 21 and although `colorControlNormal` and `colorControlActivated` changes the color of the underline to white even when clicked, it does not change the name of the word "Email". Is there a way to change the name of the word "Email" as well which appears at the top of the TextBox? – SilentDev May 07 '18 at 17:52
  • wouldn't you just add a textColor to white attribute in the style? – juztcode Apr 25 '20 at 14:19