我从像这样的api中获取长描述文字
{"status":true,"data":[{"id":674,"product_category_id":1,"child_category_id":1,"child_category_two_id":null,"child_category_three_id":null,"supplier_id":2,"supplier_name":"\u0627\u0644\u0645\u062f\u064a\u0631 \u0627\u0644\u0639\u0627\u0645","option_category_id":null,"tax_id":1,"barcode":0,"low_price":114,"image":"1586519373.jpeg","cost":115,"name_ar":"\u0633\u0644\u0629 \u0627\u0645\u0633\u0648 \u0627\u0644\u063a\u0630\u0627\u0626\u064a\u0629","name_en":"Amso food basket","details_ar":"\u0648\u0627\u062d\u062f \u0643\u064a\u0633 \u0623\u0631\u0632 \u0623\u0628\u0648 \u0643\u0627\u0633 \u062e\u0645\u0633\u0629 \u0643\u064a\u0644\u0648\r\n\u0648\u0627\u062d\u062f \u062d\u0644\u064a\u0628 \u0628\u0648\u062f\u0631\u0629 \u0627\u0644\u0641 \u0648\u062b\u0645\u0627\u0646\u0645\u0627\u0626\u0629 \u062c\u0631\u0627\u0645\r\n\u0648\u0627\u062f \u0632\u064a\u062a \u0627\u0644\u0641 \u0648\u0633\u062a\u0645\u0627\u0626\u0629 \u062c\u0645\r\n\u0648\u0627\u062d\u062f \u0634\u0639\u064a\u0631\u064a\u0629 \u0627\u0631\u0628\u0639\u0645\u0627\u0626\u0629 \u0648\u062e\u0645\u0633\u0648\u0646 \u062c\u0645\r\n\u0648\u0627\u062d\u062f \u0645\u0639\u062c\u0648\u0646 \u0637\u0645\u0627\u0637\u0645 \u062b\u0645\u0627\u0646\u0645\u0626\u0629 \u0648\u0639\u0634\u0631 \u062c\u0645\r\n\u062b\u0644\u0627\u062b \u0639\u0644\u0628 \u0641\u0648\u0644 \u0645\u062f\u0645\u0633 \u0627\u0644\u0641 \u0648\u0645\u0627\u0626\u062a\u064a\u0646 \u062c\u0645\r\n\u062b\u0644\u0627\u062b \u0639\u0644\u0628 \u062a\u0648\u0646\u0629 \u062e\u0645\u0633\u0645\u0627\u0626\u0629 \u0648\u062e\u0645\u0633\u0648\u0646 \u062c\u0645\r\n\u0648\u0627\u062d\u062f \u0633\u0643\u0631 \u0627\u062b\u0646\u064a\u0646 \u0643\u064a\u0644\u0648\r\n\u0627\u062b\u0646\u064a\u0646 \u0645\u0639\u0643\u0631\u0648\u0646\u0629 \u0645\u062a\u0646\u0648\u0639\u0647 \u0627\u0644\u0641 \u062c\u0645","details_en":"one Abu kas rice five kg one powdered milk on thousand and eight hundred gm one vegetable oil on thousand and six hundred gm one fine noodles four hundred fifty gm one tomato paste eight hundred and ten gm three beans cans three tuna cans one sugar two Kg two mixed pasta one kg","sumInv":500,"campaign":{"id":null,"product_id":null,"price":null,"purchasesLimits":null,"stock":null},"packages":[{"package_id":2436,"package_price":"114.2900","unit_count":1,"existing":0,"virtual":500}]}],"last_page":1,"current_page":1,"per_page":16}
,但是当我在textview中显示时,这个问题很奇怪
在阿拉伯语和英语中,看起来似乎有所不同,在阿拉伯语中,每个单词之间几乎都有空格,但是在英语中,它出现在第1,2和3行中,位于某些单词之前。
这是textview上的代码,哪个容器是一个约束布局
<TextView
android:id="@+id/tv_activity_detail_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textSize="12dp"
android:textColor="@color/colorDarkGray"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cardView" />
最佳答案
我发现了unicode字符的问题,因此当我尝试使用unicode字符显示文本时,它为我提供了当前屏幕,但是我得到了Unicode的真实文本,并且显示得很好,无论如何,我通过使用文本作为Java中的HTML:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
textView.setText(Html.fromHtml(user.getInput(), Html.FROM_HTML_MODE_LEGACY));
} else {
textView.setText(Html.fromHtml(user.getInput()));
}
我从此answer获得了解决方案
关于java - textview中的Android文字词之间的距离很长,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61149541/