<TextView
android:id="@+id/txtSender"
style="@android:style/TextAppearance.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:background="@drawable/sender_bubble"
android:gravity="center_vertical"
android:maxEms="11"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="15dp"
android:paddingTop="5dp"
android:text="1234567"
android:autoLink="all"
android:textColor="@color/color_black"
android:textIsSelectable="true"
android:visibility="visible" />
This is my textview in customcell. When i click on textview it is not allowing me to select the text in textview. It is working perfect in my xperia 4.2.2 but when i run the same code in device having version 4.4.4, it is not working.
NOTE : When i set the same android:textIsSelectable="true" property to the Textview which is not in Listview, it works fine in 4.4.4. Listview just move to bottom and resets to its original position within half of a second.
In my case it wasn't working because I had textView in xml layout with android:visibility="gone" property and made it visible later in adapter code. So, you need call this after you makes textview visible
textView.setTextIsSelectable(true);
Remove android:descendantFocusability="blocksDescendants"
in the recyclerview or listview to prevent the blocking of selection
Also, change the textview layout width from match_parent
to wrap_content
to prevent the selectable text feature to be disabled when reusing the text cell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With