android - TextView 中的 HTML : problems with frame layout scrolling and image viewing

标签 android textview

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<TextView
    android:id="@+id/htmlText"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:textColor="#FFCC00" />

</FrameLayout>

如果我这样设置 textview 的文本:

setText(Html.fromHtml(htmlString));

滚动不起作用。 此外,如果在 html 中有一个 img 标签,则无法查看图像..为什么?

编辑:

我切换到 WebView :

WebView view = (WebView)findViewById(R.id.newsView);
view.loadData(htmlString,"text/html","UTF-8");

现在我解决了这些问题,但我还有其他问题:

1)如何设置透明背景以便我可以看到我的应用程序?

2)如何设置前景文本颜色,以便再次看到我的应用程序的颜色?

3)如果有img标签图片不适合view,导致横向滚动。相反,文本完美填充。

最佳答案

如果要显示 HTML 内容,请使用 WebView . TextView仅支持有限的 HTML 标记集 - 主要用于格式化文本。

关于android - TextView 中的 HTML : problems with frame layout scrolling and image viewing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12296099/

相关文章:

Android TextView 问题

android - 如何在 Textview 中搜索单词?

android - TextView 重力不适用于希伯来语

java - 如何在java/android中将JPG图像转换为字符串

android - 未声明的标识符 'setfscreation' AOSP

java - 有没有一种方法可以同时使用布局宽度和高度的权重

android - 如何以编程方式在右侧Textview设置图像

Android ImageGetter 图像重叠文本

android - 在服务中未收到 CountDownTimer 回调

android - 手机的名称/型号存储在 android 代码的哪个位置,它是如何存储在那里的?