android - Custom TextView XML Drawable with backround property -


i using horizontal listview (list contains textview) , use xml drawable show line below list item whatever user taps.

as use in sliding tabs, check below screenshot, in example user has selected tab1 ,and tab2 & tab3 in normal state.

enter image description here

in same way implement custom drawable same effect textview , that, following this link.

but still did not success, see textview's property:

<textview     android:text="@string/app_name"     android:layout_height="wrap_content"     android:id="@+id/textview1"     android:layout_width="wrap_content"             android:layout_margin="5dp"     android:textcolor="#000000"     android:textappearance="?android:attr/textappearancemedium"     android:background="@drawable/custom_textview"     android:ellipsize="marquee" /> 

custom_textview.xml:

<?xml version="1.0" encoding="utf-8"?>  <selector xmlns:android="http://schemas.android.com/apk/res/android">     <item android:state_selected="true">         <layer-list>             <item>                 <shape>                     <solid android:color="#ffff7a00" />                 </shape>             </item>             <item android:bottom="3dp">                 <shape>                     <solid android:color="#222222" />                 </shape>             </item>         </layer-list>     </item> </selector> 

replace custom_textview.xml,with code

 <?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="#ffff7a00" />         </shape>     </item>      <item         android:bottom="2dp">         <shape android:shape="rectangle">             <solid android:color="#222222" />         </shape>     </item> </layer-list> 

Comments