I need to design EditText with base line showed in below image and it will be change to some other color when it receives focus.!
I needed the same thing, and I solved it in the following way:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_window_focused="true">
<shape>
<stroke android:color="@color/blue_500" android:width="2dp" />
<corners android:radius="45dp"/>
</shape>
</item>
<item android:state_focused="false" android:state_window_focused="false">
<shape>
<stroke android:color="@color/grey_600" android:width="2dp"/>
<corners android:radius="45dp"/>
</shape>
</item>
</selector>
You can add theme for EditText
<style name="EditTextTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorControlNormal">@color/primary</item>
<item name="colorControlActivated">@color/primary</item>
<item name="colorControlHighlight">@color/primary</item>
</style>
And you can use in EditText as
<EditText
android:id="@+id/edtCode"
android:layout_width="match_parent"
android:layout_height="40dp"
.......................
android:theme="@style/EditTextTheme">
</EditText>
For changing the baseline of EditText when it is on focus you can simply go to the colors.xml file in your project and change the "colorAccent" value.
res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
...
<color name="colorAccent">#DESIRED_COLOR</color>
</resources>`
Try Holo Color generator for custom colors.
Android Holo Colors
You can create Selector and set it as background of the EditText
res/drawable/edit_text.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_window_focused="false"
android:state_enabled="true"
android:drawable="@drawable/textfield_default" />
<item
android:state_window_focused="false"
android:state_enabled="false"
android:drawable="@drawable/textfield_disabled" />
<item
android:state_pressed="true"
android:drawable="@drawable/textfield_pressed" />
<item
android:state_enabled="true"
android:state_focused="true"
android:drawable="@drawable/textfield_selected" />
<item
android:state_enabled="true"
android:drawable="@drawable/textfield_default" />
<item
android:state_focused="true"
android:drawable="@drawable/textfield_disabled_selected" />
<item
android:drawable="@drawable/textfield_disabled" />
</selector>
layout :
<EditText
android:id="@+id/mobilenumber"
....
android:background="@drawable/edit_text" />
use this in your editText style
<item name="backgroundTint">@color/focus_tint_list</item>
focus_tint_list.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:color="?attr/colorAccent"/>
<item android:state_focused="false" android:color="#999999"/>
</selector>