【问题标题】:Android TextView ellipsize error with Html Text带有 Html 文本的 Android TextView ellipsize 错误
【发布时间】:2014-12-26 04:16:18
【问题描述】:

我在 TextView 中遇到了椭圆大小的问题。

这里是html字符串:

final String str = "His followed carriage proposal entrance <br/>directly had elegance. Greater for cottage gay parties natural. Remaining he furniture on he discourse suspected perpetual. <br/>Power dried her taken place day ought the. Four and our ham west miss."

我创建了 2 个文本视图(tv_test_html,tv_test_normal)。

<TextView
            android:id="@+id/tv_test_html"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:maxLines="3"
            android:ellipsize="end"
            android:text="Hello"
            />
<TextView
            android:layout_marginTop="20dp"
            android:id="@+id/tv_test_normal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:maxLines="3"
            android:ellipsize="end"
            android:text="Hello"
            />

在我设置的代码中:

 final TextView tvTestHtml = (TextView) findViewById(R.id.tv_test_html);
 final TextView tvTestNormal = (TextView) findViewById(R.id.tv_test_normal);
 tvTestHtml.setText(Html.fromHtml(str));
 tvTestNormal.setText(str);

当我运行应用程序时:

当我使用 Html.fromHtml(...); 时,你可以看到 "..." 是错误的;

那我该如何解决呢?

提前致谢!

[我只是更新图像]

【问题讨论】:

标签: android textview


【解决方案1】:

用它替换字符串:His followed carriage proposal entrance &lt;br&gt;directly had elegance. Greater for cottage gay parties natural. Remaining he furniture on he discourse suspected perpetual. &lt;br&gt;Power dried her taken place day ought the. Four and our ham west miss.

【讨论】:

  • 是将
    替换为
  • 它仍然不适合我。我认为问题是文本视图的宽度。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-07
  • 1970-01-01
  • 2016-07-26
  • 1970-01-01
  • 1970-01-01
  • 2017-12-31
相关资源
最近更新 更多