I have tried to change the underline color of my EditText with the help of this thread.
I did the same thing - this is the EditText
with the android:background
set as @drawable/edt_bg_selector
.
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:id="@+id/editText4"
android:layout_weight="1"
android:elevation="0dp"
android:background="@drawable/edt_bg_selector" />
My edt_bg_selector
:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/edt_bg_selected" />
<item android:state_focused="false" android:drawable="@drawable/edt_bg_normal" />
</selector>
... edt_bg_normal.xml
...
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:bottom="1dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape android:shape="rectangle" >
<stroke
android:width="1px"
android:color="@color/colorWhite" />
<solid android:color="#00FFFFFF" />
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
</shape>
</item>
</layer-list>
... and the last, edt_bg_selected.xml
.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:bottom="1dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape android:shape="rectangle" >
<stroke
android:width="1px"
android:color="@color/colorWhite" />
<solid android:color="#00FFFFFF" />
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
</shape>
</item>
</layer-list>
With this code I can see the color of underline has changed to white in Design Editor of Android Studio. But when I run this project on android device, the changes haven't been made. Selected EditText
's underline is my primaryColor
and unselected EditText
is black.
Android studio design editor:
Project run on android device:
Does this have anything to do with the selected theme of my application? Or what did I miss?