Skip to content

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

License

Notifications You must be signed in to change notification settings

vanniktech/TextBuilder

Repository files navigation

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)
      .italic()
      .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.4.0'
compile 'com.vanniktech:textbuilder:0.5.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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published