Skip to content

santaevpavel/OutlineSpan

Repository files navigation

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