There is a ScrollView in which I add a View, I need to be able to select the nested element (TextView) for these View. I made a selector, it responds to pressing, and changes color, but when I release it - it takes on the same appearance (color). Question: how to keep the item in the "pressed" state?
item_in_scroll_view.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="5dp" android:paddingTop="5dp" android:paddingLeft="10dp"> <TextView android:id="@+id/lblMsgFrom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="12dp" android:textColor="@color/grey" android:textStyle="italic" android:padding="5dp"/> <TextView android:id="@+id/txtMsg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16dp" android:layout_marginRight="80dp" android:textColor="@color/grey" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="5dp" android:paddingBottom="5dp" android:background="@drawable/chat_massage_slector"/> </LinearLayout>
selector.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- pressed --> <item android:drawable="@color/colorRed" android:state_pressed="true"/> <!-- focused --> <item android:drawable="@color/colorRed" android:state_focused="true"/> <!-- default --> <item android:drawable="@color/bg_message_from"/> </selector>
android:checable="true"
forTextView
andandroid:state_checked="true"
to selector? - YurySPb ♦clickable
? - YurySPb ♦