TextBuilder

Easily build cool looking texts for TextView

License

License

GroupId

GroupId

com.vanniktech
ArtifactId

ArtifactId

textbuilder
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

aar
Description

Description

TextBuilder
Easily build cool looking texts for TextView
Project URL

Project URL

https://github.com/vanniktech/TextBuilder
Source Code Management

Source Code Management

https://github.com/vanniktech/TextBuilder

Download textbuilder

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
androidx.annotation » annotation jar 1.0.0

runtime (1)

Group / Artifact Type Version
androidx.appcompat » appcompat jar 1.1.0

Project Modules

There are no modules declared in this project.

TextBuilder

Provides a Class with a builder pattern for building beautiful text super easily. Internally it uses the Spannable API.

new TextBuilder(this) // Context
    .addText(R.string.some_text)
    .addWhiteSpace()
    .addColoredTextRes("in green", R.color.green)
    .addWhiteSpace()
    .addColoredText("and blue", Color.BLUE)
    .addWhiteSpace()
    .into(textView);

Also certain parts of a text can be formatted:

new TextBuilder(this) // Context
    .addFormableText("Terms of use and privacy terms")
    .format("Terms of use")
      .textColor(Color.RED)
      .bold()
      .clickable(() -> Log.d(TAG, "Clicked on Terms of Use"))
    .done()
    .format("privacy terms")
      .underline()
      .bold()
      .clickable(() -> Log.d(TAG, "Clicked on Privacy Terms"))
    .done()
    .into(textView);

Displaying images is also not a problem:

new TextBuilder(this)
    .addDrawable(R.drawable.ic_done_black_18dp)
    .addWhiteSpace()
    .addText("Shopping")
    .addNewLine()
    .addText("Cleaning")
    .into(textView);

For now only the basic things are supported and some features may be lacking. I'm open for any suggestions or new APIs.

Setup

build.gradle

compile 'com.vanniktech:textbuilder:0.2.0'
compile 'com.vanniktech:textbuilder:0.3.0-SNAPSHOT'

Modules are located on Maven Central.

Proguard

No configuration needed.

License

Copyright (C) 2017 Vanniktech - Niklas Baudy

Licensed under the Apache License, Version 2.0

Versions

Version
0.2.0
0.1.0