11

Can I change the line color on EditText. When is active it has some greenish color.Image

Is it possible to change only the color of line when is active, and how can I do this...?

4
  • it is possible, it is embedded in the background image of the view. Commented Nov 26, 2014 at 14:31
  • How can I change it...? Commented Nov 26, 2014 at 14:32
  • 4
    You can use this site android-holo-colors.com to create a custom theme for your EditText or other android component Commented Nov 26, 2014 at 14:32
  • @Rami Don't rely on tools to do magical stuff for you. Learn how themes are created. Commented Sep 27, 2015 at 21:02

9 Answers 9

10

You need to set background source for an edit text.

  1. Generate it http://android-holo-colors.com/
  2. Than you can apply generated drawable as background like android:background="@drawable/my_theme_edit_text" for the custom EditText. Or you can set that background in your app theme - you will find example in .zip file from that site
Sign up to request clarification or add additional context in comments.

1 Comment

Than maybe you should modify .png files to remove that corners. Or just replace them with your own?
10

add to your themes.xml this line:

<item name="colorAccent">@color/black</item> 

this sets the default color for colorControlActivated which is used to tint widgets

Comments

9

Here you are:

editText.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP); 

Comments

9

You can set background of edittext to a rectangle with minus padding on left, right and top to achieve this.

Here is the xml example for setting different line colors for focused and not focused edittext, just set it as background of edittext.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:top="-2dp" android:left="-2dp" android:right="-2dp" android:bottom="2dp"> <selector > <item android:state_enabled="true" android:state_focused="true"> <shape android:shape="rectangle"> <stroke android:width="2dp" android:color="#6A9A3A"/> </shape> </item> <item android:state_enabled="true"> <shape android:shape="rectangle"> <stroke android:width="1dp" android:color="#000000"/> </shape> </item> </selector> </item> </layer-list> 

Comments

6
<EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:background="@drawable/text" android:ems="10" android:textColorHint="#fefefe" android:hint="@string/text1" android:textColor="#fefefe" android:inputType="textEmailAddress" android:layout_marginTop="10dp" /> 

Use the below code in your res/drawable/text.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:top="24.0dp"> <shape > <solid android:color="#fefefe" /> </shape> </item> </layer-list> 

Comments

5

you can set android:backgroundTint="@color/blue" to change the color of the Edittext bottom line

Comments

1

I had the same problem solved it by changing the color of the backgroundTint as follows -

android:backgroundTint="@color/light_color"

Comments

0

You can use the android:background = "@color/black" for the api 21 or above 21 (This will apply for lollypop device or above versions) and for below versions you should use the style to the edittext.

Comments

0

If your using TextInputLayouts for EditText, we should change the following properties.

<item name="colorControlNormal">#c5c5c5</item> <item name="colorControlActivated">@color/your color</item> <item name="colorControlHighlight">@color/your color</item> 

By default colour is colorAccent.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.