All Projects → SufficientlySecure → Html Textview

SufficientlySecure / Html Textview

Licence: apache-2.0
TextView to display simple HTML

Programming Languages

java
68154 projects - #9 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to Html Textview

Rotatingtext
A periodic text updating library
Stars: ✭ 1,558 (-36.28%)
Mutual labels:  textview
Collapsibletextview
show or hide part of text only in a TextView
Stars: ✭ 135 (-94.48%)
Mutual labels:  textview
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-93.54%)
Mutual labels:  textview
Typewriterview
Android library for typewriter like effects
Stars: ✭ 124 (-94.93%)
Mutual labels:  textview
Tytext
text asynchronous rendering by TextKit for iOS
Stars: ✭ 127 (-94.81%)
Mutual labels:  textview
Sharpview
安卓带有尖角气泡的控件(TextView,ImageView,EditText,Layout),支持渐变色,圆角等自定义属性
Stars: ✭ 137 (-94.4%)
Mutual labels:  textview
Szmentionsswift
Library to help handle mentions
Stars: ✭ 109 (-95.54%)
Mutual labels:  textview
Slantedtextview
Android slanted TextView.
Stars: ✭ 2,197 (-10.14%)
Mutual labels:  textview
Fading Text View
A TextView that changes its content automatically every few seconds
Stars: ✭ 1,691 (-30.84%)
Mutual labels:  textview
Vectorcompattextview
One VectorCompatTextView suits for hundreds of CompoundDrawable style. 一个库,满足CompoundDrawable的百变风格。
Stars: ✭ 147 (-93.99%)
Mutual labels:  textview
Drawabletextview
自定义控件 :drawable 跟随TextView居中 The drawable follows the text centered
Stars: ✭ 124 (-94.93%)
Mutual labels:  textview
Xrichtext
一个Android富文本类库,支持图文混排,支持编辑和预览,支持插入和删除图片。
Stars: ✭ 1,639 (-32.97%)
Mutual labels:  textview
Fstextview
继承于UITextView的自定义TextView, 带placeholder和可限制最大输入字符数, 已适配横竖屏切换.
Stars: ✭ 140 (-94.27%)
Mutual labels:  textview
Android Textview Linkbuilder
Insanely easy way to define clickable links within a TextView.
Stars: ✭ 1,549 (-36.65%)
Mutual labels:  textview
Android Lib Verticalmarqueetextview
A custom TextView with vertical marquee effect
Stars: ✭ 163 (-93.33%)
Mutual labels:  textview
Pull To Refresh
ESPullToRefresh is developed and maintained by Vincent Li. If you have any questions or issues in using ESPullToRefresh, welcome to issue. If you want to contribute to ESPullToRefresh, Please submit Pull Request, I will deal with it as soon as possible.
Stars: ✭ 1,591 (-34.93%)
Mutual labels:  textview
Textview Rich Drawable
Android TextView with rich support of compound drawables
Stars: ✭ 136 (-94.44%)
Mutual labels:  textview
Rskplaceholdertextview
A light-weight UITextView subclass that adds support for placeholder.
Stars: ✭ 192 (-92.15%)
Mutual labels:  textview
Supertextview
🎀 SuperTextView for Android 是一个在TextView的基础上扩展了几种动画效果的控件。
Stars: ✭ 165 (-93.25%)
Mutual labels:  textview
Toggleedittextview
Easily switch between EditText and TextView seamlessly.
Stars: ✭ 146 (-94.03%)
Mutual labels:  textview

Project stopped

This project has been stopped. 4.0 is the last release.

Feel free to fork this project and take over maintaining.

HtmlTextView for Android

HtmlTextView 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 import

Add this to your build.gradle:

repositories {
    jcenter()
}

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

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 tags

Tags supported by Android (history of Html class)

Extended support by HtmlTextView

  • <ul>
  • <ol>
  • <li>
  • <code>
  • <center>
  • <strike>

Support for HTML tables

HtmlTextView 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:

  1. implement a ClickableTableSpan which provides access to the table HTML (which can be forwarded to a WebView)

  2. provide a DrawTableLinkSpan which defines what the table link should look like (i.e. text, text color, text size)

Take a look at the project's sample app for an example.

Support for A tag click listener

textView.setOnClickATagListener(new OnClickATagListener() {

    @Override
    public void onClick(View widget, @Nullable String href) {
        Toast.makeText(MainActivity.this, href, Toast.LENGTH_SHORT).show();
    }
});

We recognize the standard table tags:

  • <table>
  • <tr>
  • <th>
  • <td>

as well as the tags extended by HtmlTextView. However, support doesn’t currently extend to tags natively supported by Android (e.g. <b>, <big>, <h1>) which means tables will not include the extra styling.

Changelog

4.0

3.9

  • Add A tag click listener

3.8

  • Add HtmlFormatter for use with standard TextView

3.7

  • Fix #166
  • Migrated to AndroidX

3.6

  • Improve and fix indentions

3.5

  • Allow image compression

3.4

  • Fix textIsSelectable

3.3

  • Fix text cutting bug
  • Prevent EmptyStackException when processing malformed li tags

3.2

  • Indenting entries of ordered lists the same way as of unordered lists
  • Fix OutOfMemory

3.1

  • Override handling of <ul> <ol> and <li> tags done by newer versions of Android SDK (removes empty lines between items)

3.0

  • Removed deprecated methods and classes
  • Fix out of bounds issue

2.0

  • Introduce better API

License

Apache License v2

See LICENSE for full license text.

Authors

Contributions

Feel free to fork and do pull requests. I am more than happy to merge them. Please do not introduce external dependencies.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].