HtmlTextView for Android
16lz
2021-01-23
HtmlTextView for Android
HtmlTextView is an extended TextView component for Android, which can load HTML and converts it into Spannable for displaying it. It is a replacement for usage of the WebView component, which behaves strange on some Android versions, flickers while loading, etc.
Tags supported by Android (history of Html class)
handled exactly like
(bug on some Android versions: generates italic)
(bug on some Android versions: generates bold)
,
,
,
,
,
Extended support by HtmlTextView
The library also includes a workaround to prevent TextView from crashing on specific Android versionsand the possibility to load images from local drawables folder or from the Internet.
This library is kept tiny without external dependencies. I am using it to provide Help/About Activities in my apps.
Example
https://www.it610.com/article/HtmlTextView text https://www.it610.com/article/= https://www.it610.com/article/new https://www.it610.com/article/HtmlTextView(https://www.it610.com/article/this);https://www.it610.com/article/// loads html from string and displays cat_pic.png from the app's drawable foldertexthttps://www.it610.com/article/.setHtmlFromString(https://www.it610.com/article/https://www.it610.com/article/"Hello wold
\"cat_pichttps://www.it610.com/article/\"/>https://www.it610.com/article/", https://www.it610.com/article/true);
- cats
- dogs
or
https://www.it610.com/article/HtmlTextView text https://www.it610.com/article/= https://www.it610.com/article/new https://www.it610.com/article/HtmlTextView(https://www.it610.com/article/this);https://www.it610.com/article/// loads html from string and displays http://www.example.com/cat_pic.png from the Internettexthttps://www.it610.com/article/.setHtmlFromString(https://www.it610.com/article/https://www.it610.com/article/"Hello wold
\"http://www.example.com/cat_pic.pnghttps://www.it610.com/article/\"/>https://www.it610.com/article/", https://www.it610.com/article/false);
- cats
- dogs
or
https://www.it610.com/article/HtmlTextView text https://www.it610.com/article/= https://www.it610.com/article/new https://www.it610.com/article/HtmlTextView(https://www.it610.com/article/this);https://www.it610.com/article/// loads html from raw resource, i.e., a html file in res/raw/, this allows translatable resource (e.g., res/raw-de/ for german)texthttps://www.it610.com/article/.setHtmlFromRawResource(https://www.it610.com/article/this, https://www.it610.com/article/Rhttps://www.it610.com/article/.rawhttps://www.it610.com/article/.help, https://www.it610.com/article/true);
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer