Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 854 Bytes

README.md

File metadata and controls

25 lines (19 loc) · 854 Bytes

RoundedBackgroundSpan

It's simple implementation of background span with rounded corners for Android.

Usage

  1. Copy RoundedBackgroundColorSpan in your project.

  2. Use it from your code:

    private fun initSpannableText() {
        val span = RoundedBackgroundColorSpan(
            backgroundColor = colors.random(),
            padding = dp(5), 
            radius = dp(5)
        )
        
        with(spanText) {
            setShadowLayer(dp(10), 0f, 0f, 0) // it's important for padding working

            text = buildSpannedString { inSpans(span) { append(str) } }
        }
    }