android:singleLine 的 TextView 不再在 "Deprecated"中?

标签 android textview deprecated

我遇到了 android:ellipsize 的问题,它在 TextView 中不起作用。 但要适用于 android:singleLine。

我听说 android:singleLine 已被“弃用”,但它没有写在 Android Developer 的引用资料中。

https://developer.android.com/reference/android/widget/TextView.html#attr_android:singleLine

android:singleLine 不再处于“已弃用”状态?

添加: 我自己解决了这个问题。

事实证明,TextView的属性android:scrollHorizo​​ntally="true"并没有反射(reflect)在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);

但是,我在 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"
/>

最佳答案

也尝试将 IME 输入设置为短文本或类似内容。它可能会起作用。 elipsize 有很多问题,我也曾遇到过,但未能解决。在我的例子中,它主要连接到 editTexts 和其他组件,将焦点从 View 上移开。需要焦点才能让 Elipsize 工作。

关于android:singleLine 的 TextView 不再在 "Deprecated"中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7026121/

相关文章:

Maven:使用已弃用的类/方法进行报告

iphone - 如何获取 hidesAccessoryWhenEditing 的功能

Android:录制 SoundPool 输出

android - 向动态 Android TextView 添加边距

android - 索尼 SmartWatch2 : hooking back key

android - margin 设置为 textView 的第一行

java - 无法在 TextView 中获得双输出

java [弃用] DataInputStream 中的 readLine() 已被弃用?

android - 如何禁用 Firebase 应用分发的电子邮件通知

java - 启动服务不起作用