Bugzilla Asked: 2020-06-17 01:54:05 +0800 CST 2020-06-17 01:54:05 +0800 CST 2020-06-17 01:54:05 +0800 CST TextView with various styles 772 Is it possible to create a single TextView and place several texts with different styles in it? Expected result If it is not possible to do it with a single TV, what would be the best way? All the best android 1 Answers Voted Best Answer rockbass2560 2020-06-17T03:17:39+08:002020-06-17T03:17:39+08:00 Yes, it is possible using the SpannableString or SpannableStringBuilder class if we want the string to be mutable. val textView : TextView = findViewById(R.id.textview) val spannableText = SpannableString("Texto a cambiar dentro del span") spannableText.span= TextAppearanceSpan(context, R.style.myStyle), 0, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) spannableText.setSpan(TextAppearanceSpan(context, R.style.myNextStyle), 6, 10, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) textView.text = spannableText
Yes, it is possible using the SpannableString or SpannableStringBuilder class if we want the string to be mutable.