Skip to content

Repository files navigation

EasySpannableText


Simple SpannableString Builder.


Content List


Download

Add maven jitpack.io and dependencies in build.gradle (Project) :

// build.gradle projectallprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
// build.gradle app/moduledependencies {
...
implementation 'com.github.gzeinnumer:EasySpannableText:version'
}

Feature List


Tech stack and 3rd library


Usage

Customize Text Style in TextView

intsizeInDp = 21;
intcolor = ContextCompat.getColor(this, R.color.purple_500);
CharSequencesequence = newSpannableBuilder(getApplicationContext())
.text(Typeface.NORMAL,"text\n")
.textColor(Typeface.BOLD,"textColor\n", color)
.textSize(Typeface.ITALIC,"textSize\n", sizeInDp)
.textSizeColor(Typeface.BOLD_ITALIC,"textSizeColor\n", sizeInDp, color)
.build();
textView.setText(sequence); //or textView.setText(sequence, TextView.BufferType.SPANNABLE);

Typeface optional value

  • Typeface.NORMAL
  • Typeface.BOLD
  • Typeface.ITALIC
  • Typeface.BOLD_ITALIC

Preview :

Text Style With CallBack

add 1 parameter in function .text(),.textColor(),.textSize(),.textSizeColor(). and add setMovementMethod() after setText(). Example.

intsizeInDp = 21;
intcolor = ContextCompat.getColor(this, R.color.purple_500);
CharSequencesequence = newSpannableBuilder(getApplicationContext())
.text(Typeface.NORMAL, "text\n", newSpannableCallBack() {
@OverridepublicvoidonClick() {
Toasttoast = Toast.makeText(MainActivity.this, "Tekan 1", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP, 0, 0);
toast.show();
}
})
.textColor(Typeface.BOLD, "textColor\n", color, newSpannableCallBack() { ... })
.textSize(Typeface.ITALIC, "textSize\n", sizeInDp, newSpannableCallBack() { ... })
.textSizeColor(Typeface.BOLD_ITALIC, "textSizeColor\n", sizeInDp, color, newSpannableCallBack() { ... })
.build();
textView.setText(sequence); //or textView.setText(sequence, TextView.BufferType.SPANNABLE);textView.setMovementMethod(LinkMovementMethod.getInstance());

Preview :


Example Code/App

Without OnClick & With OnClick


Version

  • 1.0.0
    • First Release
  • 1.0.1
    • Value in DP

Contribution

You can sent your constibution to branchopen-pull.

Fore More All My Library


Copyright 2021 M. Fadli Zein

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages