Unable to verify that this is a mistake.
<TextView android:layout_width="wrap_content" android:layout_height="?android:attr/listPreferredItemHeightSmall" android:ellipsize="start" android:focusable="true" android:gravity="center_vertical" android:singleLine="true" android:textIsSelectable="true"/>
Please note that we set android:ellipsize="start" in xml - more on this later.
mTextView = (TextView) findViewById(R.id.tv); mTextView.post(new Runnable() { @Override public void run() { mTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE); mTextView.setSelected(true); } });
setEllipsize(TruncateAt) checks if the current ellipsize value ellipsize the specified one. To get around this, we supply android:ellipsize="start" in xml. Thus, TextView has no problem accepting TextUtils.TruncateAt.MARQUEE later.
Now, although this works, I suggest you not do this. You can understand why - as soon as you try this code. It seems that textIsSelectable not supposed to be used with marquee - selection descriptors do not move along with the text.
All in all, it looks extremely sketchy.
Vikram
source share