【发布时间】: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(...); 时,你可以看到 "..." 是错误的;
那我该如何解决呢?
提前致谢!
[我只是更新图像]
【问题讨论】:
-
您发布的图片有问题,我看不到。可以上传到别的地方吗?
-
请更新您的问题。图片未显示
-
这可能会对您有所帮助。 stackoverflow.com/q/17131294/2504200
-
非常感谢!问题是“\n”字符。所以我需要自定义 TextView :|