小编zak*_*aki的帖子

android:单行链接的TextView在"已弃用"中不再存在?

我面临的问题是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:scrollHorizo​​ntally ="true"没有反映在xml文件中.

所以,我尝试使用setHorizo​​ntallyScrolling方法,它起作用了.

*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)

android deprecated textview

6
推荐指数
1
解决办法
6915
查看次数

标签 统计

android ×1

deprecated ×1

textview ×1