3

I know this question has been asked before but that solution are not working in my case. I want to change edit text bottom line color and tried the solution from other links to add this line to theme in styles.xml

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

but somehow this is not working in my case. I tried changing base theme but still not working for me. And I want to do this with all editext in my app, not just only one. Are there any other ways of doing it??

Sharath
  • 691
  • 8
  • 23
Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84

7 Answers7

3

Edit Style.xml under values folder.

<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorControlNormal">#c5c5c5</item>
    <item name="colorControlActivated">#c5c5c5</item>
    <item name="colorControlHighlight">#c5c5c5</item>
</style>
Sharath
  • 691
  • 8
  • 23
1

create a file edittextborder.xml in drawable folder and write

 ?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">

        <item><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
                <solid android:color="#ffffff" />


            </shape></item>

    </selector>

and Set this file as:

android:background="@drawable/edittextborder"

in editText.

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
Rohit Heera
  • 2,709
  • 2
  • 21
  • 31
1

This can be changed in xml by using:

android:backgroundTint="@color/blue"
Jigar Shekh
  • 2,800
  • 6
  • 29
  • 54
0

I preferred to use 9 patch images for edit text custom color. Android 9 patch generator online

This is awesome online tool generator for all widgets.Android Holo colors

generate and download for every dpi folder. and apply it using background.

0

Solution follows as below-

  1. I want u to visit Android Holo Colors Generator.
  2. Provide a Theme name and select a color u want.
  3. Select the components u want to change the color. In ur case its Edittext.
  4. Finally click on Download Zip.
  5. Extract the Zip and use it in ur proj.
kevz
  • 2,727
  • 14
  • 39
0

Try this one,

.xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:padding="5dp">

    <EditText
        android:id="@+id/text_to"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/customborder" //.xml file for edittext
        android:clickable="true"
        android:padding="5dip"
        android:text="Text_to"
        android:textColor="@color/black"
        android:textSize="@dimen/font_normal_size" />
</LinearLayout>

customborder.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners
        android:radius="2dp"
        android:topRightRadius="0dp"
        android:bottomRightRadius="0dp"
        android:bottomLeftRadius="0dp" />
    <stroke
        android:width="1dp"
        android:color="@android:color/white" />
</shape>
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
0

Using Rohit's answer and a hack provided from this link Android Bottom Stroke only.I was able to achieve my desired behaviour. Here is the code for drawable folder file.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <shape android:shape="rectangle" >
            <solid android:color="@android:color/transparent" />
        </shape>
    </item>

    <item android:top="-2dp" android:right="-2dp" android:left="-2dp">
        <shape>
            <solid android:color="@android:color/transparent" />
            <stroke

                android:width="1dp"
                android:color="#FFFFFF" />
        </shape>
    </item>

</layer-list>
Community
  • 1
  • 1
Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84