机器人:TextView中的单线是nolonger在"德precated"? [英] android:singleLine of TextView is nolonger in the "Deprecated"?

查看:137
本文介绍了机器人:TextView中的单线是nolonger在"德precated"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在面临的android的一个问题:ellipsize中不TextView的工作。
但要为Android效果很好。SINGLELINE

我听说过的android:SINGLELINE是pcated德$ P $,但它没有在Android开发者参考书面

<一个href=\"http://developer.android.com/intl/ja/reference/android/widget/TextView.html#attr_android%3asingleLine\" rel=\"nofollow\">http://developer.android.com/intl/ja/reference/android/widget/TextView.html#attr_android:singleLine

安卓?SINGLELINE不再在pcated德$ P $

新增:
我解决了这个问题喽。

事实证明,Android的:TextView中的属性scrollHorizo​​ntally =true是不会反映在xml文件

所以,我试图用setHorizo​​ntallyScrolling方法,它的工作。

  * XML:*
&LT;的TextView
  机器人:ID =@ + ID /文
  机器人:ellipsize =结束
  机器人:layout_width =match_parent
  机器人:layout_height =WRAP_CONTENT
/&GT;* code:*
TextView中的TextView =(TextView中)findViewByID(R.id.text);
textView.setHorizo​​ntallyScrolling(真);

不过,我想补充的android:inputType下=TEXT像下面的XML,这是行不通的。
请注意。

  * XML:*
&LT;的TextView
  机器人:ID =@ + ID /文
  **的android:inputType下=文本**
  机器人:ellipsize =结束
  机器人:layout_width =match_parent
  机器人:layout_height =WRAP_CONTENT
/&GT;


解决方案

我不知道,如果安卓的TextView的单线是nolonger在pcated德$ P $,因为TextView中的德precated构造函数中,有关于SINGLELINE结构的评论..


  

//如果设置,输入类型改写了使用去precated单行标志设置。


  
  

SINGLELINE = isMultilineInputType(inputType下!);


来源$ C ​​$ C:的<一个围绕1156L href=\"https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/TextView.java\"相对=nofollow>核心/ JAVA /安卓/空间/ TextView.java - 平台/框架/基 - 的Git在谷歌

由于谷歌留下评论说,单行标志德precated,(虽然它没有在开发者网站上写的),可能是这样的。

I am facing a problem of android:ellipsize that doesn't work in TextView. But to work well for android:singleLine.

I've heard that android:singleLine is "Deprecated", but it is not written in the reference in Android Developer.

http://developer.android.com/intl/ja/reference/android/widget/TextView.html#attr_android:singleLine

android:singleLine is no longer in the "Deprecated"?

ADDED: I solved this problem myself.

As it turns out, android:scrollHorizontally="true" of TextView's attribute is not reflected in xml file.

So, I tried to use setHorizontallyScrolling method, it worked.

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

but, I add "android:inputType="text" in xml like following, it doesn't work. Please be careful.

*xml:*
<TextView
  android:id="@+id/text"
  **android:inputType="text"**
  android:ellipsize="end"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
/>

解决方案

I am not sure if android:singleLine of TextView is nolonger in the "Deprecated", because inside the deprecated constructor of TextView, there is a comment with regard to singleLine configuration..

// If set, the input type overrides what was set using the deprecated singleLine flag.

singleLine = !isMultilineInputType(inputType);

Source code: around 1156L of core/java/android/widget/TextView.java - platform/frameworks/base - Git at Google

Since Google leaves a comment saying that singleLine flag is deprecated, (although it is not written in the developer site) it may be so.

这篇关于机器人:TextView中的单线是nolonger在&QUOT;德precated&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆