我面临的问题是android:ellipsize在TextView中不起作用.但要适用于android:singleLine.
我听说android:singleLine是"Deprecated",但它不是在Android Developer的引用中写的.
https://developer.android.com/reference/android/widget/TextView.html#attr_android:singleLine
android:singleLine不再处于"弃用"状态?
补充: 我自己解决了这个问题.
事实证明,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);
Run Code Online (Sandbox Code Playgroud)
但是,我在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"
/>
Run Code Online (Sandbox Code Playgroud)