我在TextView中遇到了ellipsize的问题。
这是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个textview(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(...);
时,你会看到“...”是错误的那我该如何解决呢?
提前致谢!
[我只是更新图片]
答案 0 :(得分:0)
用它替换字符串: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.