2

嗨,我在 textview 中包装文本时遇到问题。我希望 textView 进行字符换行。我有这个日文文本“コーヒーイベントを行いますよ!!!11月23日19时より开催予定です。コーヒーイベントを行いますよ!”

布局是这样的

<LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal"
         >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" />
        <TextView
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:id="@+id/textViewToUpdate"
        />
    </LinearLayout>

但是当我设置textViewToUpdate为日文字符时,字符显示为

コーヒーイベントを行います <free space - here>
よ!!!11月23日19時より開催予定です。コーヒーイベントを行いますよ!

我希望它显示如下,你是怎么做的?

我不知道 TextView 有什么问题。在 iOS 中,有“字符换行”选项。在 Android 中它不可用。

コーヒーイベントを行いますよ!!!11月23日19時より開催予定です。コーヒ
ーイベントを行いますよ!

更新:当我在 WebView 中尝试相同的文本时,我能够使用 css 属性修复它

<span style='word-break:break-all;'>--japanese text here-- </span>

所以它按我的预期显示。你如何在 textView 上应用相同的概念?我努力了 :

textViewToUpdate.setText(Html.fromHtml("<html><body><u><span style='word-break:break-all;'>"+japaneseStr+"</span></u></body></html>"));

但没有运气。似乎是什么问题?

4

0 回答 0