0

I want to have a string Bold into a textView with Kotlin, here's my code :

 val priceTxt = "10.000" ///example
    
    val s = SpannableStringBuilder()
                .append("starting from")
                .append(" ")
                .append(currency)
                .append(" ")
                .bold { append(priceTxt) }
     txtviewPrice.text = s

I want to get the following result : "starting from $ 10.000"

What should I change in my code to make it as the example above ?

Lina
  • 553
  • 10
  • 34
  • 1
    Does this answer your question? [how to make a specific text on TextView BOLD](https://stackoverflow.com/questions/14371092/how-to-make-a-specific-text-on-textview-bold) – deHaar Sep 02 '20 at 08:35
  • Does this answer your question? [How to set TextView textStyle such as bold, italic](https://stackoverflow.com/questions/6200533/how-to-set-textview-textstyle-such-as-bold-italic) – LoukasPap Sep 02 '20 at 08:43

1 Answers1

0

Price text should be SpannableString

I would recommend you to modify your code adding this lines:

val priceTxt = SpannableString("10.000")
priceTxt.setSpan(StyleSpan(Typeface.BOLD), 0, priceTxt.length)

and

.append(priceTxt)

to your builder