#99CBFF #CEF7F6

How to set border color for EditText

I used this.

<color name="edt_pressed">#99CBFF</color> <color name="edt_focused">#CEF7F6</color> <color name="edt_default">#000000</color> 

gradient_edt_focused

 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:width="1dip" android:color="@color/edt_focused" /> </shape> 

edt_border.xml

 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true" android:drawable="@layout/gradient_edt_pressed"/> <item android:state_focused="true" android:drawable="@layout/gradient_edt_focused"/> <item android:drawable="@layout/gradient_edt_default"/> </selector> 

activity_main.xml

 <EditText android:id="@+id/uname" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:background="@layout/textview_border"/> 

Now the border works fine, but when typing that has a background color of black.

+4
source share
1 answer

The problem is that the default color of the element is the background during focus, since there was no solid color for each of them. So now I have added this to "gradient_edt_focused".

 <solid android:color="#00000000" /> 

Now it works.

+5
source

Source: https://habr.com/ru/post/1484970/


All Articles