android - 让 TextView 换行

标签 android textview word-wrap

我知道这个问题已经被问过很多次了,但我似乎仍然无法解决这个问题。 我已经尝试了各种组合,但它只是拒绝换行到 2 行。

现在是这样的:

    <TextView
        android:id="@+id/doctor_details_clinic_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingRight="3dip"
        android:textSize="12sp"
        android:maxLines="1"
        android:layout_gravity="right"
        android:gravity="right"
        android:scrollHorizontally="false"
        android:singleLine="false"
        android:ellipsize="none"
        />

我试过将宽度设置为 0dip 和所有其他建议但没有一致。

最佳答案

首先,您应该将最大行数设置为 2 而不是 1。 像这样的东西会起作用:

    <TextView
        android:id="@+id/myText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:maxLines="2"
        android:ellipsize="end"
        android:text="this is the most interesting use of text view I have seen so far,this is the most interesting use of text view I have ever seen so far,this is the most interesting use of text view I have ever seen so far this is the most interesting use of text view I have ever seen so far"/>

关于android - 让 TextView 换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12067302/

相关文章:

ios - UITextView 中的文本显示不正确,不可见,但占用空间

android - 通过单击通知打开图库文件夹

java - 引入ExecutorService后TextView setText不起作用

android - 文本大小(dp)

Android 浏览器视口(viewport)和媒体查询不适用于自动换行和图像缩放

html - CSS 网格中的自动换行

android - 如何正确组合 NavigationView 和 BottomNavigationView

java - 在另一个对话框的单击事件中创建对话框的问题

android - Ionic 应用程序中的 "cordova already defined"

java - 如何从 RecycleAdapter 获取值并设置为 MainActivity Text?