{"id":13644365,"url":"https://github.com/SufficientlySecure/html-textview","last_synced_at":"2025-04-21T07:31:00.344Z","repository":{"id":10393516,"uuid":"12544206","full_name":"SufficientlySecure/html-textview","owner":"SufficientlySecure","description":"TextView to display simple HTML","archived":true,"fork":false,"pushed_at":"2020-09-07T11:23:50.000Z","size":394,"stargazers_count":2545,"open_issues_count":38,"forks_count":494,"subscribers_count":84,"default_branch":"master","last_synced_at":"2024-04-30T00:45:28.623Z","etag":null,"topics":["android","android-library","textview"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SufficientlySecure.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-02T16:19:18.000Z","updated_at":"2024-04-28T08:06:34.000Z","dependencies_parsed_at":"2022-07-14T00:50:30.184Z","dependency_job_id":null,"html_url":"https://github.com/SufficientlySecure/html-textview","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SufficientlySecure%2Fhtml-textview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SufficientlySecure%2Fhtml-textview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SufficientlySecure%2Fhtml-textview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SufficientlySecure%2Fhtml-textview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SufficientlySecure","download_url":"https://codeload.github.com/SufficientlySecure/html-textview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250014612,"owners_count":21360982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","textview"],"created_at":"2024-08-02T01:02:01.956Z","updated_at":"2025-04-21T07:30:59.824Z","avatar_url":"https://github.com/SufficientlySecure.png","language":"Java","readme":"# Project stopped\n\nThis project has been stopped. 4.0 is the last release.\n\nFeel free to fork this project and take over maintaining.\n\n# HtmlTextView for Android\n\nHtmlTextView is an extended TextView component for Android, which can load **very simple** HTML by converting it into Android Spannables for viewing.\n\nIn addition to a small set of HTML tags, the library allows to load images from the local drawables folder or from the Internet.\n\nThis library is kept tiny without external dependencies.\n\n## How to import\n\nAdd this to your build.gradle:\n\n```\nrepositories {\n    jcenter()\n}\n\ndependencies {\n    compile 'org.sufficientlysecure:html-textview:4.0'\n}\n```\n\n## Example\n\n```java\n\u003corg.sufficientlysecure.htmltextview.HtmlTextView\n            android:id=\"@+id/html_text\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            android:textAppearance=\"@android:style/TextAppearance.Small\" /\u003e\n```\n\n```java\nHtmlTextView htmlTextView = (HtmlTextView) view.findViewById(R.id.html_text);\n\n// loads html from string and displays cat_pic.png from the app's drawable folder\nhtmlTextView.setHtml(\"\u003ch2\u003eHello wold\u003c/h2\u003e\u003cul\u003e\u003cli\u003ecats\u003c/li\u003e\u003cli\u003edogs\u003c/li\u003e\u003c/ul\u003e\u003cimg src=\\\"cat_pic\\\"/\u003e\",\n    new HtmlResImageGetter(htmlTextView));\n```\n\nor\n\n```java\nHtmlTextView htmlTextView = (HtmlTextView) view.findViewById(R.id.html_text);\n\n// loads html from string and displays cat_pic.png from the app's assets folder\nhtmlTextView.setHtml(\"\u003ch2\u003eHello wold\u003c/h2\u003e\u003cul\u003e\u003cli\u003ecats\u003c/li\u003e\u003cli\u003edogs\u003c/li\u003e\u003c/ul\u003e\u003cimg src=\\\"cat_pic\\\"/\u003e\",\n    new HtmlAssetsImageGetter(htmlTextView));\n```\n\nor\n\n```java\nHtmlTextView htmlTextView = (HtmlTextView) view.findViewById(R.id.html_text);\n\n// loads html from string and displays http://www.example.com/cat_pic.png from the Internet\nhtmlTextView.setHtml(\"\u003ch2\u003eHello wold\u003c/h2\u003e\u003cimg src=\\\"http://www.example.com/cat_pic.png\\\"/\u003e\",\n    new HtmlHttpImageGetter(htmlTextView));\n```\n\nor\n\n```java\nHtmlTextView htmlTextView = (HtmlTextView) view.findViewById(R.id.html_text);\n\n// loads html from raw resource, i.e., a html file in res/raw/,\n// this allows translatable resource (e.g., res/raw-de/ for german)\nhtmlTextView.setHtml(R.raw.help, new HtmlHttpImageGetter(htmlTextView));\n```\n\nor\n\n\n```java\n\u003cTextView\n    android:id=\"@+id/html_text\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:textAppearance=\"@android:style/TextAppearance.Small\" /\u003e\n```\n\n```java\nTextView htmlTextView = (TextView) view.findViewById(R.id.html_text);\n\n// loads html from string and displays cat_pic.png from the app's drawable folder\nSpanned formattedHtml = HtmlFormatter.formatHtml(new HtmlFormatterBuilder().setHtml(\"\u003ch2\u003eHello wold\u003c/h2\u003e\u003cul\u003e\u003cli\u003ecats\u003c/li\u003e\u003cli\u003edogs\u003c/li\u003e\u003c/ul\u003e\u003cimg src=\\\"cat_pic\\\"/\u003e\").setImageGetter(new HtmlResImageGetter(htmlTextView.getContext())));\nhtmlTextView.setText(formattedHtml);\n```\n\n## Supported HTML tags\n\n### Tags supported by Android ([history of Html class](https://github.com/android/platform_frameworks_base/commits/master/core/java/android/text/Html.java))\n* ``\u003cp\u003e``\n* ``\u003cdiv\u003e`` handled exactly like ``\u003cp\u003e``\n* ``\u003cbr\u003e``\n* ``\u003cb\u003e``\n* ``\u003ci\u003e``\n* ``\u003cstrong\u003e`` ([bug on some Android versions: generates italic](https://code.google.com/p/android/issues/detail?id=3473))\n* ``\u003cem\u003e`` ([bug on some Android versions: generates bold](https://code.google.com/p/android/issues/detail?id=3473))\n* ``\u003cu\u003e``\n* ``\u003ctt\u003e``\n* ``\u003cdfn\u003e``\n* ``\u003csub\u003e``\n* ``\u003csup\u003e``\n* ``\u003cblockquote\u003e``\n* ``\u003ccite\u003e``\n* ``\u003cbig\u003e``\n* ``\u003csmall\u003e``\n* ``\u003cfont color=\"...\" face=\"...\"\u003e``\n* ``\u003ch1\u003e``, ``\u003ch2\u003e``, ``\u003ch3\u003e``, ``\u003ch4\u003e``, ``\u003ch5\u003e``, ``\u003ch6\u003e``\n* ``\u003ca href=\"...\"\u003e``\n* ``\u003cimg src=\"...\"\u003e``\n\n### Extended support by HtmlTextView\n* ``\u003cul\u003e``\n* ``\u003col\u003e``\n* ``\u003cli\u003e``\n* ``\u003ccode\u003e``\n* ``\u003ccenter\u003e``\n* ``\u003cstrike\u003e``\n\n### Support for HTML tables\nHtmlTextView 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:\n\n1. implement a `ClickableTableSpan` which provides access to the table HTML (which can be forwarded to a WebView)\n\n2. provide a `DrawTableLinkSpan` which defines what the table link should look like (i.e. text, text color, text size)\n\nTake a look at the project's [sample app](https://github.com/SufficientlySecure/html-textview/blob/master/example/src/main/java/org/sufficientlysecure/htmltextview/example/MainActivity.java) for an example.\n\n### Support for A tag click listener\n```\ntextView.setOnClickATagListener(new OnClickATagListener() {\n\n    @Override\n    public void onClick(View widget, @Nullable String href) {\n        Toast.makeText(MainActivity.this, href, Toast.LENGTH_SHORT).show();\n    }\n});\n```\n\n\nWe recognize the standard table tags:\n\n* ``\u003ctable\u003e``\n* ``\u003ctr\u003e``\n* ``\u003cth\u003e``\n* ``\u003ctd\u003e``\n\nas well as the tags extended by HtmlTextView. However, support doesn’t currently extend to tags natively supported by Android (e.g. ``\u003cb\u003e``, ``\u003cbig\u003e``, ``\u003ch1\u003e``) which means tables will not include the extra styling.\n\n### Changelog\n\n#### 4.0\n* [A tag click enhancements](https://github.com/SufficientlySecure/html-textview/pull/191)\n* [Blockquote styling feature](https://github.com/SufficientlySecure/html-textview/pull/189)\n* [Image placeholder](https://github.com/SufficientlySecure/html-textview/pull/186)\n* Removed deprecated functions\n\n#### 3.9\n* Add A tag click listener\n\n#### 3.8\n* Add HtmlFormatter for use with standard TextView\n\n#### 3.7\n* Fix [#166](https://github.com/SufficientlySecure/html-textview/issues/166)\n* Migrated to AndroidX\n\n#### 3.6\n* Improve and fix indentions\n\n#### 3.5\n* Allow image compression\n\n#### 3.4\n* Fix textIsSelectable\n\n#### 3.3\n* Fix text cutting bug\n* Prevent EmptyStackException when processing malformed li tags\n\n#### 3.2\n* Indenting entries of ordered lists the same way as of unordered lists\n* Fix OutOfMemory\n\n#### 3.1\n* Override handling of ``\u003cul\u003e`` ``\u003col\u003e`` and ``\u003cli\u003e`` tags done by newer versions of Android SDK (removes empty lines between items)\n\n#### 3.0\n* Removed deprecated methods and classes\n* Fix out of bounds issue\n\n#### 2.0\n* Introduce better API\n\n## License\nApache License v2\n\nSee LICENSE for full license text.\n\n## Authors\n- This library was put together by Dominik Schürmann\n- Original [HtmlTagHandler](https://gist.github.com/mlakkadshaw/5983704) developed by [Mohammed Lakkadshaw](http://blog.mohammedlakkadshaw.com/)\n- Original [HtmlHttpImageGetter](https://gist.github.com/Antarix/4167655) developed by Antarix Tandon\n- Original [HtmlResImageGetter](http://stackoverflow.com/a/22298833) developed by drawk\n- [JellyBeanSpanFixTextView](https://gist.github.com/pyricau/3424004) (with fix from comment) developed by Pierre-Yves Ricau\n- [Table support](https://github.com/SufficientlySecure/html-textview/pull/33) added by Richard Thai\n- [setRemoveFromHtmlSpace](https://github.com/SufficientlySecure/html-textview/pull/37) added by [Derek Smith](https://github.com/derekcsm)\n\n## Contributions\n\nFeel free to fork and do pull requests. I am more than happy to merge them.\nPlease do not introduce external dependencies.\n","funding_links":[],"categories":["TextView"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSufficientlySecure%2Fhtml-textview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSufficientlySecure%2Fhtml-textview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSufficientlySecure%2Fhtml-textview/lists"}