Skip to content

Instantly share code, notes, and snippets.

@chetdeva
Last active January 23, 2018 10:23
Show Gist options
  • Save chetdeva/3d7e29120782863606f218a889a15a83 to your computer and use it in GitHub Desktop.
Save chetdeva/3d7e29120782863606f218a889a15a83 to your computer and use it in GitHub Desktop.
textView.setText(new Truss()
.appendSelectiveln("With Snippety, you can use:", "Snippety",
new Snippety().textColor(Color.RED))
.appendln()
.pushSpan(new Snippety().typeface(typeface)) // TextTypefaceSpan
.appendln("typeface for TypefaceSpan")
.popSpan()
.appendln("fontStyle for StyleSpan",
new Snippety().fontStyle(Snippety.FontStyle.BOLD)) // StyleSpan
.appendln("fontStyle for Stylespan",
new Snippety().fontStyle(Snippety.FontStyle.ITALIC)) // StyleSpan
.appendln("textColor for ForegroundColorSpan",
new Snippety().textColor(Color.MAGENTA)) // ForegroundColorSpan
.appendln("backgroundColor for BackgroundColorSpan",
new Snippety().backgroundColor(Color.YELLOW)) // BackgroundColorSpan
.appendln("roundedBackgroundColor\nfor RoundedBackgroundSpan",
new Snippety().roundedBackgroundColor(Color.RED, Color.WHITE)) // RoundedBackgroundSpan
.appendln("textSizeAbsolute for AbsoluteSizeSpan",
new Snippety().textSizeAbsolute(textSize)) // AbsoluteSizeSpan
.appendln("textSizeRelative for RelativeSizeSpan",
new Snippety().textSizeRelative(1.2f)) // RelativeSizeSpan
.appendln("textMultiColor for MultiColorSpan",
new Snippety().textMultiColor(colorsRainbow)) // MultiColorSpan
.appendln("underline for UnderlineSpan",
new Snippety().underline()) // UnderlineSpan
.append("image for ImageSpan")
.appendln(new Snippety().image(drawable)) // ImageSpan
.appendln("quote for QuoteSpan",
new Snippety().quote(Color.RED)) // QuoteSpan
.appendln("strikethrough for StrikethroughSpan",
new Snippety().strikethrough()) // StrikethroughSpan
.appendln("align for AlignmentSpan",
new Snippety().align(Snippety.Indent.RIGHT)) // AlignmentSpan
.appendln("url for URLSpan",
new Snippety().url("http://developer.android.com")) // URLSpan
.appendln("addOnClickListener for ClickableSpan",
new Snippety().textColor(Color.BLUE).addOnClickListener(new Snippety.OnClickListener() {
@Override
public void onClick() {
Toast.makeText(getContext(), "Thanks for stopping by!", Toast.LENGTH_SHORT).show();
}
})) // ClickableSpan
.build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment