How to change line color in EditText
This is the best tool that you can use for all views and its FREE many thanks to @Jérôme Van Der Linden.
The Android Holo Colors Generator allows you to easily create Android components such as EditText
or spinner with your own colours for your Android application. It will generate all necessary nine patch assets plus associated XML drawable and styles which you can copy straight into your project.
http://android-holo-colors.com/
UPDATE 1
This domain seems expired but the project is an open source you can find here
https://github.com/jeromevdl/android-holo-colors
try it
this image put in the background of EditText
android:background="@drawable/textfield_activated"
UPDATE 2
For API 21 or higher, you can use android:backgroundTint
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Underline color change"
android:backgroundTint="@android:color/holo_red_light" />
Update 3
Now We have with back support AppCompatEditText
Note: We need to use app:backgroundTint instead of android:backgroundTint
<android.support.v7.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Underline color change"
app:backgroundTint="@color/blue_gray_light" />
Update 4
AndroidX version
<androidx.appcompat.widget.AppCompatEditText
app:backgroundTint="@color/blue_gray_light" />
Changing EditText bottom line color with appcompat v7
Finally, I have found a solution. It simply consists of overriding the value for colorControlActivated
, colorControlHighlight
and colorControlNormal
in your app theme definition and not your edittext style. Then, think to use this theme for whatever activity you desire. Below is an example:
<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>
How to change bottom line color of EditText?
Use :
editText.getBackground().mutate().setColorFilter(getResources().getColor(R.color.your_color), PorterDuff.Mode.SRC_ATOP);
Note : getColor()
method is deprecated for API level 23
. So you need to use Contextcompat to get color.
How do I change the color of the blob on an Android EditText view?
You can change it for all EditText
with setting the accent color in AppTheme
:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light">
<item name="colorPrimary">#FF5722</item>
<item name="colorAccent">#CDDC39</item>
</style>
Or just for a single EditText using Theme
on your EditText
:
<style name="MyEditText" parent="Theme.AppCompat.Light">
<item name="colorControlNormal">#FF5722</item>
<item name="colorControlActivated">#CDDC39</item>
</style>
After that apply your @style
on the EditText
:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hint text"
android:theme="@style/MyEditText"
/>
Result:
Change color bottom line of EditText
Use this :
mEditText.getBackground().setColorFilter(YOUR_COLOR_HERE, PorterDuff.Mode.SRC_IN);
eg :
mEditText.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN)
Related Topics
Platform.Runlater and Task in Javafx
Set Margins in a Linearlayout Programmatically
Android - Programmatically Hide/Show Soft Keyboard
Why Does Tomcat Work with Port 8080 But Not 80
Java Animation Programs Running Jerky in Linux
How to Call Method in Jar File with Terminal
Java Error When Trying to Run Netlogo Headlessly on a Cluster
From What Linux Kernel/Libc Version Is Java Runtime.Exec() Safe with Regards to Memory
Can You Use @Autowired With Static Fields
How to Parse JSON Array with Gson
Differencebetween List and Arraylist
Firebase No Properties to Serialize Found on Class
Difference Between Using Java.Library.Path and Ld_Library_Path
File.Encoding Has No Effect, Lc_All Environment Variable Does It
In Linux, How to Execute Java Jar File with External Jar Files