A fast and simplified spannable string builder.
On-going development available at Projects Section.
- Fast
- Simplified Spannable APIs
- Lightweight
Beautifully designed typography posters made with Spanly!
Spanly Spans |
---|
bold() |
italic() |
underline() |
strike() |
sup() |
sub() |
background(color: Int) |
color(color: Int) |
size(size: Float) |
font(typeface: Typeface) |
clickable(listener: View.OnClickListener, isUnderlineText: Boolean = false) |
// MainActivity.kt
// Design 1
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Render sample font
val fontAvenirBold = Typeface.createFromAsset(assets, "fonts/avenir_bold.ttc")
val fontBrillianteRegular = Typeface.createFromAsset(assets, "fonts/brilliante_regular.ttf")
// Sample usage
tvMessage.text =
Spanly()
.append(
"TALK",
font(fontAvenirBold),
size(1.5f),
italic(),
clickable(View.OnClickListener {
startActivity(Intent(this, SubActivity::class.java))
finish()
}),
color(ContextCompat.getColor(this, R.color.colorOrange))
)
.space()
.append("IS", font(fontAvenirBold), color(Color.WHITE), underline(), size(1.5f))
.next()
.append(
"Cheap",
font(fontBrillianteRegular),
size(5f),
clickable(View.OnClickListener {
startActivity(Intent(this, SubActivity::class.java))
finish()
}),
color(ContextCompat.getColor(this, R.color.colorBlueLight))
)
// Important for the click to work
// More on https://developer.android.com/reference/android/text/method/LinkMovementMethod
tvMessage.movementMethod = LinkMovementMethod.getInstance()
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
// Replace version with release version, e.g. 1.0.0-alpha, -SNAPSHOT
implementation 'io.jmdg:spanly:[VERSION]'
}
Spanly is released under the MIT License. See LICENSE for details.
- Fork it (https://github.com/joshuadeguzman/Spanly/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request