3

I have this working, but redundant, code:

feedbackView.text = SpannableStringBuilder()
    .scale(.6f) { italic { append(getString(R.string.suggestion_prefix)) } }
    .scale(.6f) { append("\n\n") }
    .scale(.6f) { bold { append(s) } }

How would I refactor it so there is only one call to .scale()?

When I try this, only the first string is scaled:

feedbackView.text = SpannableStringBuilder()
    .scale(.6f, { italic { append(getString(R.string.suggestion_prefix)) } })
    .append("\n\n")
    .bold { append(s) }

I have not been able to figure out the syntax to include everything in the lambda argument to scale().

Ellen Spertus
  • 6,576
  • 9
  • 50
  • 101

1 Answers1

3

You can put everything inside one scale lambda.

feedbackView.text = SpannableStringBuilder()
    .scale(.6f) {
        italic { append(getString(R.string.suggestion_prefix)) }
        .append("\n\n")
        .bold { append(s) }
     }
Merov
  • 1,028
  • 1
  • 14
  • 29