I would like to change the blue colour below the edit text, i don't know what property it is.
I tried using a different background colour for it but it didn't work.
I've attached an image below:
Custom Subject Modification UnderlineAdd an EditText to activity_main. xml, and add the android:theme="@style/MyEditText" attribute. The effect is as follows: As you can see, the color of the cursor and underline will be changed, but the spacing will remain.
You can define the underlined text in an Android layout XML using a String Resouce XML file. In a string res file you have to use an HTML underline tag <u> </u> .
There is a really practical and easy way to remove underline for a text. And that is: textview. setPaintFlags(View. INVISIBLE);
It's actually fairly easy to set the underline color of an EditText programmatically (just one line of code).
To set the color:
editText.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
To remove the color:
editText.getBackground().clearColorFilter();
Note: when the EditText has focus on, the color you set won't take effect, instead, it has a focus color.
API Reference:
Drawable#setColorFilter
Drawable#clearColorFilter
Use android:backgroundTint=""
in your EditText
xml layout.
For api<21 you can use AppCompatEditText
from support library thenapp:backgroundTint=""
You have to use a different background image, not color, for each state of the EditText
(focus, enabled, activated).
http://android-holo-colors.com/
In the site above, you can get images from a lot of components in the Holo theme. Just select "EditText" and the color you want. You can see a preview at the bottom of the page.
Download the .zip file, and copy paste the resources in your project (images and the XML).
if your XML is named: apptheme_edit_text_holo_light.xml (or something similar):
Go to your XML "styles.xml" and add the custom EditText
style:
<style name="EditTextCustomHolo" parent="android:Widget.EditText">
<item name="android:background">@drawable/apptheme_edit_text_holo_light</item>
<item name="android:textColor">#ffffff</item>
</style>
Just do this in your EditText
:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/EditTextCustomHolo"/>
And that's it, I hope it helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With