在android TextView中逐字换行 [英] Wrap text by word in android TextView

查看:34
本文介绍了在android TextView中逐字换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一段信息的文本视图.我想让文本按单词而不是按字符换行.目前,如果单词太长,它会插入一个连字符并在单词中间打断.

I have a text view that contains a paragraph of information. I would like to make the text wrap by word not by character. Currently if the word is to long it will insert a hyphen and break in the middle of the word.

这是我用于 TextView 的 xml 代码

This is my xml code for the TextView

    <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>

感谢您的帮助.

推荐答案

这是 android 6 Marshmellow 中的新事物.

This is a new thing in android 6 Marshmellow.

尝试将其添加到您的 TextView

Try adding this to your TextView

android:hyphenationFrequency="none"

这篇关于在android TextView中逐字换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆