如何设置多行TextView?

时间:2015-08-19 11:27:21

标签: android android-layout

我在TextView中有Android,其中显示了从数据库中检索到的信息,因此我不知道将使用多少行来显示信息。

这是我的TextView

<TextView
    android:id="@+id/lblInfo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:inputType="textMultiLine"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textSize="15sp" />

我尝试了将属性android:inputType="textMultiLine"放到我身上,但它给了我一个建议:

  

属性android:inputType不应与<TextView>一起使用:将元素类型更改为<EditText>

我在互联网上搜索但是在所有答案中他们都知道他们需要的最大行数,因此他们使用了android:maxLines="the maximum of lines they want"android:lines="the total of lines that the TextView has"这个属性,但我不想这样做,因为我没有&#39 ;知道我在TextView中会有多少行。

如何使用未定义行数制作TextView

提前致谢!

1 个答案:

答案 0 :(得分:0)

使用以下xml。希望它能奏效。

value