简体   繁体   English

Android:如何制作多行TextView?

[英]Android: How to make multiline TextView?

Good day! 美好的一天!

I have a ListView with news list, but if the title is very long- he lost on the edge of the screen. 我有一个带有新闻列表的ListView,但是如果标题很长,他会迷失在屏幕边缘。

How do I text-wrap to the next line? 如何将文字换行到下一行? I read many posts about this, but can not find solution that works to me. 我阅读了许多与此相关的文章,但找不到适合我的解决方案。

Here the code: 这里的代码:

<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" 
    >
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.app.SportNewsReaderApp.NewsActivity" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world"

    android:textSize="16.5dip"
    android:padding="2dip"
    android:minLines = "1"
    android:maxLines = "100"
    android:singleLine = "false"
    android:inputType="textMultiLine"
    android:scrollHorizontally="false" 
    android:lines="2"
    />

</LinearLayout>

How do I text-wrap to the next line? 如何将文字换行到下一行?

by removing minLines attribute 通过删除minLines属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM