百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
H

html-textview

> 编程语言
开源

用于显示简单HTML的TextView

2.6K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用于显示简单HTML的TextView

项目已停止

本项目已停止维护。4.0 是最后一个发布版本。

欢迎 fork 本项目并接手维护。

适用于 Android 的 HtmlTextView

HtmlTextView 是 Android 的一个扩展 TextView 组件,它可以通过将非常简单的 HTML 转换为 Android Spannable 对象来显示内容。

除了支持一小部分 HTML 标签外,该库还允许从本地 drawables 文件夹或互联网加载图片。

该库保持小巧,无外部依赖。

如何导入

将以下内容添加到你的 build.gradle 中:

repositories {
    jcenter()
}

dependencies {
    compile 'org.sufficientlysecure:html-textview:4.0'
}

示例

java
<org.sufficientlysecure.htmltextview.HtmlTextView
            android:id="@+id/html_text"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textAppearance="@android:style/TextAppearance.Small" />
java
HtmlTextView htmlTextView = (HtmlTextView) view.findViewById(R.id.html_text);

// loads html from string and displays cat_pic.png from the app's drawable folder
htmlTextView.setHtml("<h2>Hello wold</h2><ul><li>cats</li><li>dogs</li></ul>",
    new HtmlResImageGetter(htmlTextView));

或

java
HtmlTextView htmlTextView = (HtmlTextView) view.findViewById(R.id.html_text);

// loads html from string and displays cat_pic.png from the app's assets folder
htmlTextView.setHtml("<h2>Hello wold</h2><ul><li>cats</li><li>dogs</li></ul>",
    new HtmlAssetsImageGetter(htmlTextView));

或

java
HtmlTextView htmlTextView = (HtmlTextView) view.findViewById(R.id.html_text);

// loads html from string and displays http://www.example.com/cat_pic.png from the Internet
htmlTextView.setHtml("<h2>Hello wold</h2>",
    new HtmlHttpImageGetter(htmlTextView));

或

java
HtmlTextView htmlTextView = (HtmlTextView) view.findViewById(R.id.html_text);

// loads html from raw resource, i.e., a html file in res/raw/,
// this allows translatable resource (e.g., res/raw-de/ for german)
htmlTextView.setHtml(R.raw.help, new HtmlHttpImageGetter(htmlTextView));

或

java
<TextView
android:id="@+id/html_text"
android:layout_

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaandroidandroid-librarytextview

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言