我面临 android:ellipsize 在 TextView 中不起作用的问题。
但要在 android:singleLine 上正常工作。
我听说 android:singleLine 已“弃用”,但 Android Developer 的参考中并未写入它。
https://developer.android.com/reference/android/widget/TextView.html#attr_android:singleLine https://developer.android.com/reference/android/widget/TextView.html#attr_android:singleLine
android:singleLine 不再处于“已弃用”状态?
ADDED:我自己解决了这个问题。
事实证明,TextView 属性的 android:scrollHorizontally="true" 并没有反映在 xml 文件中。
所以,我尝试使用 setHorizontallyScrolling 方法,它起作用了。
*xml:*
<TextView
android:id="@+id/text"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
*code:*
TextView textView = (TextView)findViewByID(R.id.text);
textView.setHorizontallyScrolling(true);
但是,我在 xml 中添加“android:inputType=”text”,如下所示,它不起作用。
请小心。
*xml:*
<TextView
android:id="@+id/text"
**android:inputType="text"**
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>