在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:SufficientlySecure/html-textview开源软件地址:https://github.com/SufficientlySecure/html-textview开源编程语言:Java 94.5%开源软件介绍:Project stoppedThis project has been stopped. 4.0 is the last release. Feel free to fork this project and take over maintaining. HtmlTextView for AndroidHtmlTextView is an extended TextView component for Android, which can load very simple HTML by converting it into Android Spannables for viewing. In addition to a small set of HTML tags, the library allows to load images from the local drawables folder or from the Internet. This library is kept tiny without external dependencies. How to importAdd this to your build.gradle:
Example<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" /> 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><img src=\"cat_pic\"/>",
new HtmlResImageGetter(htmlTextView)); or 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><img src=\"cat_pic\"/>",
new HtmlAssetsImageGetter(htmlTextView)); or 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><img src=\"http://www.example.com/cat_pic.png\"/>",
new HtmlHttpImageGetter(htmlTextView)); or 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)); or <TextView
android:id="@+id/html_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="@android:style/TextAppearance.Small" /> TextView htmlTextView = (TextView) view.findViewById(R.id.html_text);
// loads html from string and displays cat_pic.png from the app's drawable folder
Spanned formattedHtml = HtmlFormatter.formatHtml(new HtmlFormatterBuilder().setHtml("<h2>Hello wold</h2><ul><li>cats</li><li>dogs</li></ul><img src=\"cat_pic\"/>").setImageGetter(new HtmlResImageGetter(htmlTextView.getContext())));
htmlTextView.setText(formattedHtml); Supported HTML tagshistory of Html class)Tags supported by Android (
Extended support by HtmlTextView
Support for HTML tablesHtmlTextView now supports HTML tables (to a limited extent) by condensing the text into a link which developers are able to render in a native WebView. To take advantage of the feature you'll need to:
Take a look at the project's sample app for an example. Support for A tag click listener
We recognize the standard table tags:
as well as the tags extended by HtmlTextView. However, support doesn’t currently extend to tags natively supported by Android (e.g. Changelog4.0
3.9
3.8
3.7
3.6
3.5
3.4
3.3
3.2
3.1
3.0
2.0
LicenseApache License v2 See LICENSE for full license text. Authors
ContributionsFeel free to fork and do pull requests. I am more than happy to merge them. Please do not introduce external dependencies. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论