Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.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 如果文本太长,请避免调整文本视图的大小_Android_Android Layout_Textview - Fatal编程技术网

Android 如果文本太长,请避免调整文本视图的大小

Android 如果文本太长,请避免调整文本视图的大小,android,android-layout,textview,Android,Android Layout,Textview,我有一个TextView,当它有一个长文本时,它会调整大小以使文本适合内部,从而破坏UI 有没有办法使用XML属性使TextView不可调整大小 我正在考虑在ScrollView中使用TextView,还有其他选项吗?解决方案: <TextView android:elipsize="marquee" </TextView> 要使其工作,请将特定宽度设置为textview(它将显示textview而不滚动) 如果要显示滚动,请添加具有特定大小和内部滚动布局的滚动视图,添

我有一个TextView,当它有一个长文本时,它会调整大小以使文本适合内部,从而破坏UI

有没有办法使用XML属性使TextView不可调整大小

我正在考虑在ScrollView中使用TextView,还有其他选项吗?

解决方案:

<TextView
  android:elipsize="marquee"

</TextView>

要使其工作,请将特定宽度设置为textview(它将显示textview而不滚动)

如果要显示滚动,请添加具有特定大小和内部滚动布局的滚动视图,添加文本视图,如

<ScrollView
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:id="@+id/scrollView"
    android:fillViewport="false">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</ScrollView>

100dp是这里的虚拟尺寸

请尝试以下代码:

<TextView
android:layout_width="100dp" 
android:layout_height="wrap_content" 
android:singleLine="false" 
android:singleLine="false" 
android:text="Long multiline text"/>


如果我不在那里,我能做什么?你比我快+同样的答案是1
<TextView
android:layout_width="100dp" 
android:layout_height="wrap_content" 
android:singleLine="false" 
android:singleLine="false" 
android:text="Long multiline text"/>