[英]Multiline Textview
I Have one TextView , the text is too long can't fit in one line, How can I make this as multiline TextView? 我有一个TextView ,文本太长不能放在一行,我怎么能把它作为多行TextView? I have added
android:singleline="false"
attribute but it's not working. 我添加了
android:singleline="false"
属性,但它不起作用。
<TextView
android:text="some long text"
android:singleline="false"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
Use this 用这个
<TextView
android:id="@+id/yourTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:scrollHorizontally="false"
android:scrollbars="vertical" />
You don't need to give false the singleLine 你不需要假造singleLine
Just give the 只是给
android:maxLine="Here define the line max as you want"
this will allow your text to add the number of line in width and height you defined in it. 这将允许您的文本添加您在其中定义的宽度和高度的行数。
你可以使用android:minLines="3"
作为textview
After testing on my emulator i come here..so do this 在我的模拟器上测试后,我来到这里。所以这样做
t=(TextView)findViewById(R.id.t);
t.setText("This is first line \n This is second \n last line....");
给
android:maxLine="Define max line here"
You write in xml file for textview 您在xml文件中编写textview
android:maxLine="Define max line here" android:maxLine =“在这里定义最大线”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.