Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 停止TextView截断整个单词_Android_Textview - Fatal编程技术网

Android 停止TextView截断整个单词

Android 停止TextView截断整个单词,android,textview,Android,Textview,我正试图用android:maxLines=“1”替换android:singleLine=“true”,因为它已被弃用。当然,它没有按计划进行,这是我的问题: 如果我有一根绳子 String s = "this is a sample" 然后使用singleLine=“true”我得到如下结果: (View) +-------------+ |this is a sam| +-------------+ 但是,使用maxlines=“1”我现在可以得到: (View)

我正试图用
android:maxLines=“1”
替换
android:singleLine=“true”
,因为它已被弃用。当然,它没有按计划进行,这是我的问题:

如果我有一根绳子

String s = "this is a sample"
然后使用
singleLine=“true”
我得到如下结果:

     (View)
+-------------+
|this is a sam|
+-------------+
但是,使用
maxlines=“1”
我现在可以得到:

     (View)
+-------------+
|this is a    |
+-------------+
(在这两个版本中,我都使用了
ellipsize=“none”

因为
sample
不适合,所以它被完全删除而不是截断。问题是,我真的需要尽可能多地插入文本,它是否被剪切到单词的中间并不重要。有办法解决这个问题吗?

我想这就是你想要做的

在布局中:

<TextView
    android:layout_width="65dp"
    android:layout_height="wrap_content"
    android:ellipsize="none"
    android:inputType="text"
    android:maxLines="1"
    android:text="this is a sample"
    tools:ignore="TextViewEdits"/>

<android.support.v7.widget.AppCompatTextView
    android:layout_width="65dp"
    android:layout_height="wrap_content"
    android:ellipsize="none"
    android:inputType="text"
    android:maxLines="1"
    android:text="this is a sample"/>


检查textView设置
android:inputType=“text”
是解决该问题的部分,尚不确定是否有其他后果。