Search code examples
javaandroidandroid-studiosplittextview

Split Textview and Spannable String


guys i'm using this code below to get a textview and split the text, the text is "3,48"

TxReal = view.findViewById(R.id.valorLMin);
String ValorSeparado [] = TxReal.getText().toString().split(",");

after i using this to span

SpannableString s1 = new SpannableString(ValorSeparado[0]);
  s1.setSpan(new RelativeSizeSpan(1.5f),0,1,0);
    TxReal.setText(s1);

but when I use SetText and see it in my layout, I can't see the rest of the text just the first character "3", what should I do to show all the text with only the first largest number


Solution

  • You don't need split text, try this

    String value = TxReal.getText().toString();
    SpannableString s1 = new SpannableString(value);
    s1.setSpan(new RelativeSizeSpan(1.5f), 0, value.indexOf(','), 0);
    TxReal.setText(s1);