gpt4 book ai didi

android - TextView 中的分词

转载 作者:行者123 更新时间:2023-11-30 02:49:35 24 4
gpt4 key购买 nike

我正在使用 TextView 在我的应用程序中显示一些消息。消息包含一些 HTML 标记,因此我使用 textView.setText(Html.fromHtml(message))。但这有一个问题。具体的单词分成两行,如下所示。

enter image description here

我需要单词不拆分并且表现得像 textView.setText(message) 那样。

TextView 定义:

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:padding="@dimen/padding"

android:layout_marginTop="@dimen/marginTop"
android:layout_marginBottom="@dimen/marginBottom"
android:layout_marginLeft="0dp"
android:layout_marginRight="@dimen/marginRight"
android:gravity="left"
android:shadowColor="@color/textShadow"
android:shadowDx="1"
android:shadowDy="1"
android:text="msg"
android:textColor="@android:color/black"
android:textColorLink="@android:color/black"
android:background="@drawable/background"
android:textSize="@dimen/textSize" />

最佳答案

您有意通过使用不间断空格 ( ) 告诉 Android 不要拆分单词。用实际空格替换它们。

关于android - TextView 中的分词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24431494/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com