Whenever I use the buildAnnotatedString I must write some sort of style using ParagraphStyle or SpanStlye. Sadly none of these 2 classes have modifiers to add some padding between every text (append)
This is what I'm getting right now. There should a small space between the background and the letters at the start and at the end of every text:
This is the code with the background:
val spanStyle = (
MaterialTheme.typography.body1.copy(
color = MaterialTheme.colors.onSurface,
fontWeight = FontWeight.W400,
fontSize = 17.sp,
letterSpacing = 0.25.sp,
background = MaterialTheme.colors.surface,
baselineShift = BaselineShift(0.2f),
)).toSpanStyle()
buildAnnotatedString {
withStyle(style = spanStyle) {
append("I write text here with background")
}
}
I've checked ParagraphStyle but the only thing related to vertical space is the lineHeight which obviously increase the height of every line but not the space between them.
Is there any way to add this little small space between every append() so background isn't coupled?
Edit:
This is what I have right now:

This is what I want to achieve, the horizontal padding at the start and end inside. TextIndent doesn't work because there's not a separation between the start background and start text.


