santaevpavel / OutlineSpan

Android library for outlining text
Apache License 2.0
19 stars 2 forks source link
android library text-view

OutlineSpan

Library (just one class) for outlining TextView.

How to use

Use android's Spannable class for changing style of part of text.

val outlineSpan = OutlineSpan(
    strokeColor = Color.RED,
    strokeWidth = 4F
)
val text = "Outlined text"
val spannable = SpannableString(text)
spannable.setSpan(outlineSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)

// Set text of TextView
binding.outlinedText.text = spannable 

Result:

Download (Gradle)

Add Jitpack repository:

repositories {
    maven { url 'https://jitpack.io' }
}

Add dependency:

dependencies {
    implementation 'com.github.santaevpavel:OutlineSpan:0.1.1'
}

If you don't want to add dependency, you can copy class OutlineSpan to your project.

Sample

Link