代码之家  ›  专栏  ›  技术社区  ›  Bernard

在android TextView中按文字换行

  •  4
  • Bernard  · 技术社区  · 8 年前

    这是我的TextView的xml代码

        <ScrollView
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_above="@+id/title"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginBottom="13dp"
        android:id="@+id/scrollView2">
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
    
            <TextView
                android:id="@+id/content"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="130dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:ellipsize="start"
                android:text="TextView"
                android:textColor="#000000"
                android:textSize="16sp"
                android:visibility="visible" />
        </LinearLayout>
    </ScrollView>
    

    谢谢你的帮助。

    2 回复  |  直到 8 年前
        1
  •  7
  •   Stuckzilla    8 年前

    这是安卓6 Marshmellow中的一个新功能。

    尝试将其添加到TextView

    android:hyphenationFrequency="none"

        2
  •  -2
  •   Anton Potapov    8 年前

    你需要用/n来打断你的段落。也可以使用非中断空间来控制换行。