andreluizreis
10/25/2017 - 10:44 PM

TextView with different text sizes

[TextView with different text sizes] #android
From: https://stackoverflow.com/questions/7388361/textview-with-different-textsize

// TextView with different text sizes
// From: https://stackoverflow.com/questions/7388361/textview-with-different-textsize
// tag: #android

String symbol = mActivityReference.getString(R.string.currency_symbol);
String hr = mActivityReference.getString(R.string.hr);

int index = price.indexOf(symbol);
SpannableString span = new SpannableString(price);
span.setSpan(new RelativeSizeSpan(0.8f), index, index + 1,
    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

index = price.indexOf(hr);
if (index > 0) {
    span.setSpan(new RelativeSizeSpan(0.8f), index, index + hr.length(),
        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}

bidViewHolder.tvPrice.setText(span);