How can I make permanent underline for an EditText, with ability of color change after being focused?
I haven't found an answer in another topics.
I would like to achieve something like that:
Asked
Active
Viewed 1,132 times
1

Igor Mańka
- 125
- 1
- 1
- 7
-
have you tried this : http://stackoverflow.com/a/37101446/2632867 – Alvi Mar 05 '17 at 10:28
1 Answers
0
You can use custom style for your EditText in style.xml
like this -
<!-- Edit text -->
<style name="editTextStyle" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textSize">@dimen/auth_text_paragraph_little</item>
<item name="android:layout_gravity">left</item>
<item name="android:focusable">true</item>
<item name="colorControlNormal">@color/editUnderLine</item>
<item name="colorControlActivated">@color/colorAccent</item>
<item name="colorControlHighlight">@color/colorAccent</item>
<item name="android:textColorHint">@color/hint</item>
</style>
@color/editUnderLine
is the name of color you want to use from color.xml
file as like as string.xml
file and dimen.xml
file
and use this custom style in your XML layout-
<EditText
android:id="@+id/edt_phone_number"
style="@style/editTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/auth_margin_half"
android:padding="@dimen/auth_margin_half_plus"
android:fontFamily="@string/auth_font_family_regular"
android:hint="@string/auth_mobile_number"
android:inputType="phone"/>

Farya
- 277
- 3
- 14