Skip to content

Semper-Viventem/RoundedBackgroundSpan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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) } }
        }
    }

About

Draw rounded background for text

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages