Android 创建多行 TextView

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10815093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:05:32  来源:igfitidea点击:

Creating a multiline TextView

androidtextview

提问by Kumar

I have a TextViewthat should be 4 lines long .

我有一个TextView应该有 4 行长的。

First line text should be "YES"
Second Line ="No"
Third Line = "true"
Fourth line + "false"

How can this be done with a single TextView?

这怎么能用一个来完成TextView

回答by Ronak Mehta

try following for multilineTextView.

尝试遵循多行TextView。

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:maxLines="4" 
    android:singleLine="false" 
    android:text="YES\nNo\ntrue\nfalse" />

You can try \nto set text in next line.

您可以尝试\n在下一行设置文本。

回答by Simon

Try this:

尝试这个:

<TextView android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:lines="4"
    android:text="YES\nNo\ntrue\nfalse" />