android - Change layout of EditText on state "selected" -


i trying obtain edittext changing it's colors , layout when user clicks on type something, , custom drawable, attributes android:state_enabled="true" android:state_focused="true"> don't work @ all, meaning don't called.

edittext:

 <edittext android:id="@+id/field_user_info" android:hint="nome e cognome"         android:layout_margintop="8dp" android:layout_marginbottom="8dp"         android:padding="8dp" android:maxlines="1"         android:background="@drawable/custom_account_edittext"         android:layout_width="match_parent"          android:layout_height="wrap_content"         android:textcolorhint="@color/texthint"/> 

custom_account_edittext drawable:

<selector     xmlns:android="http://schemas.android.com/apk/res/android">      <item>         <shape android:shape="rectangle">             <!--<solid android:background="?android:attr/selectableitembackground"/>-->             <!--android:color="#ffffff" -->             <solid android:color="@color/account_grey_300" />             <stroke android:width="0.8dip"                 android:color="@color/account_grey_400"/>             <corners android:radius="2dip" /> <!--android:bottomrightradius="7dp"--><!--android:bottomleftradius="7dp"--><!--android:topleftradius="7dp"--><!--android:toprightradius="7dp"/>-->         </shape>     </item>     <item android:state_enabled="true"  android:state_focused="true">         <shape android:shape="rectangle">             <!--<solid android:background="?android:attr/selectableitembackground"/>-->             <!--android:color="#ffffff" -->             <solid android:color="@color/white" />             <stroke android:width="1dip"                 android:color="@color/cardview_blu_color600"/>             <corners android:radius="2dip" />         </shape>     </item> </selector> 

my problem visualize default layout (the first item). why items <item android:state_enabled="true" android:state_focused="true"> don't activated @ all?

how can customize textview states?

try this

<item android:state_enabled="true" android:state_focused="true"> 

edit:

try , check if background color changed when clicked on edittext

<?xml version="1.0" encoding="utf-8"?> <selector     xmlns:android="http://schemas.android.com/apk/res/android"     >     <item         android:state_pressed="true"         android:drawable="#f07c01"         /> <!-- pressed -->     <item     android:state_enabled="true" android:state_focused="true"         android:drawable="#c099cc00"         /> <!-- focused -->     <item         android:drawable="#0d91a8"         /> <!-- default --> </selector> 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -