Android EditText bottom line color and theme changes -


hello need remove edittext default style from image want remove selected portion both side on focus of edittext or on normal edittext want simple black line on normal edittext , blue line on focus

i have created 1 xml:

 <?xml version="1.0" encoding="utf-8"?>     <selector xmlns:android="http://schemas.android.com/apk/res/android">          <item android:state_pressed="true"><shape android:shape="line">                  <!-- draw 2dp width border around shape -->                 <stroke android:width="1dp" android:color="@color/blue" />             </shape>                <!-- overlap left, top , right border using background color  -->         <item             android:bottom="1dp"             >             <shape android:shape="rectangle">                 <solid android:color="@color/white"/>             </shape>         </item> <!-- pressed -->         </item>         <item android:state_focused="true"><shape android:shape="rectangle">                  <!-- draw 2dp width border around shape -->                 <stroke android:width="1dp" android:color="@color/blue" />             </shape></item>      <!-- focused -->         <item><shape android:shape="rectangle">                  <!-- draw 2dp width border around shape -->                 <stroke android:width="1dp" android:color="@color/orange" />             </shape></item>      <!-- default -->      </selector> 

but giving me rectangle want line @bottom

create new xml file inside drawable folder. lets

a.xml

<?xml version="1.0" encoding="utf-8"?>  <layer-list xmlns:android="http://schemas.android.com/apk/res/android">      <item>          <shape android:shape="rectangle">              <solid android:color="@android:color/transparent" /> <!--background color of box-->          </shape>      </item>        <item          android:top="-2dp"          android:right="-2dp"          android:left="-2dp">          <shape>              <solid android:color="@android:color/transparent" />              <stroke                  android:width="1dp"                  android:color="<focus color>" />  <!-- color of stroke -->          </shape>      </item>  </layer-list>

create new xml file in drawable, lets say

b.xml

<?xml version="1.0" encoding="utf-8"?>  <layer-list xmlns:android="http://schemas.android.com/apk/res/android">      <item>          <shape android:shape="rectangle">              <solid android:color="@android:color/transparent" /> <!--background color of box-->          </shape>      </item>        <item          android:top="-2dp"          android:right="-2dp"          android:left="-2dp">          <shape>              <solid android:color="@android:color/transparent" />              <stroke                  android:width="1dp"                  android:color="#8ac42f" />  <!-- color of stroke -->          </shape>      </item>  </layer-list>

create new xml file in drawable. lets

c.xml

<?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/a"></item>  <item android:drawable="@drawable/b">        </item>  </selector>

try code.

this selector file. has made background edittext. selector automatically switches between 2 drawable file acording (edittext's) state.

using this edittext

<edittext     android:id="@+id/id_login_emal_et"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_margin="5dp"     android:background="@drawable/c"     android:ems="10"     android:padding="10dip"     android:hint="email"     android:inputtype="textemailaddress"     > 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -