android - textview background does not change for the selected_state -
there few textviews in layout. want change color of selected textview. think textview not selectable, there anyway can set background of released state?
this text view:
<textview android:id="@+id/langdutch" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/item_selected" android:clickable="true" android:drawableleft="@drawable/bg_settings_dutchon_hc_2x" android:drawablepadding="10dp" android:focusable="true" android:gravity="center_vertical" android:onclick="onlanguageselect" android:padding="10dp" android:text="dutch" android:textcolor="#454c52" /> this item_selected.xml:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/background_grey" android:state_pressed="true"/> <item android:drawable="@color/background_hc" android:state_focused="true"/> <item android:drawable="@color/background_bf" android:state_selected="true"/> </selector>
first of change in layout, in order use selector:
android:background="@drawable/item_background" then in it, write (considering want background, when it's unselected , default):
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/background_hc" android:state_focused="true"/> <item android:drawable="@color/background_grey" android:state_focused="false"/> </selector> those 2 possible states- focused , unfcused (pressed/unpressed).
Comments
Post a Comment