HtmlBuilder

Build valid HTML for Android TextView.

License

License

GroupId

GroupId

com.jaredrummler
ArtifactId

ArtifactId

html-builder
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

HtmlBuilder
Build valid HTML for Android TextView.
Project URL

Project URL

https://github.com/jaredrummler/HtmlBuilder
Source Code Management

Source Code Management

https://github.com/jaredrummler/HtmlBuilder

Download html-builder

How to add to project

<!-- https://jarcasting.com/artifacts/com.jaredrummler/html-builder/ -->
<dependency>
    <groupId>com.jaredrummler</groupId>
    <artifactId>html-builder</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.jaredrummler/html-builder/
implementation 'com.jaredrummler:html-builder:1.0.0'
// https://jarcasting.com/artifacts/com.jaredrummler/html-builder/
implementation ("com.jaredrummler:html-builder:1.0.0")
'com.jaredrummler:html-builder:jar:1.0.0'
<dependency org="com.jaredrummler" name="html-builder" rev="1.0.0">
  <artifact name="html-builder" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.jaredrummler', module='html-builder', version='1.0.0')
)
libraryDependencies += "com.jaredrummler" % "html-builder" % "1.0.0"
[com.jaredrummler/html-builder "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
com.android.support » support-annotations jar 25.3.1

Project Modules

There are no modules declared in this project.

HTML Builder

Maven Central License API Twitter Follow

Build valid HTML for Android TextView.

Screenshot

Description

There is a lovely method on the android.text.Html class, fromHtml(), that converts HTML into a Spannable for use with a TextView.

However, the documentation does not stipulate what HTML tags are supported, which makes this method a bit hit-or-miss. This small library provides a fluent API for building valid HTML for android.widget.TextView.

Usage

HtmlBuilder html = new HtmlBuilder();
html.p("Lorem ipsum dolor sit amet, denique detraxit reprimique quo in. Ius dicat omnes mucius cu.");
html.font().color("red").face("sans-serif-condensed").text("Red Text").close();
textView.setText(html.build());

HTML Tags Supported by TextView

  • <a href="...">
  • <b>
  • <big>
  • <blockquote>
  • <br>
  • <cite>
  • <dfn>
  • <div align="...">
  • <em>
  • <font color="..." face="...">
  • <h1>
  • <h2>
  • <h3>
  • <h4>
  • <h5>
  • <h6>
  • <i>
  • <img src="...">
  • <p>
  • <small>
  • <strike>
  • <strong>
  • <sub>
  • <sup>
  • <tt>
  • <u>
  • <ul> (Android 7.0+)
  • <li> (Android 7.0+)

Download

Download the latest AAR or grab via Gradle:

compile 'com.jaredrummler:html-builder:1.0.0'

or Maven:

<dependency>
  <groupId>com.jaredrummler</groupId>
  <artifactId>html-builder</artifactId>
  <version>1.0.0</version>
  <type>aar</type>
</dependency>

License

Copyright 2016 Jared Rummler

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
1.0.0