0

I need to show the price in the Android app. Design is such that text size of two digits after the decimal point is smaller than the rest of the text. I know I can achieve this with multiple TextView views but I'm wondering if anyone did it without the use of multiple views and how to do it.

TL;DR Price should be formatted like this: 5,oo USD (oo in this example represents two zeros as in zero cents with text size smaller than the number 5 which represents the number of dollars)

Nayan Sarder
  • 512
  • 1
  • 3
  • 18
TheKarlo95
  • 1,144
  • 9
  • 17

2 Answers2

1

You can use AbsoluteSizeSpan for your TextView

SpannableStringBuilder yourText = new SpannableStringBuilder("5.00 USD");
span.setSpan(new AbsoluteSizeSpan(fontsize, true), start, end,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
yourTextView.setText(span)

You can find more information from developer webpage

Ergin Ersoy
  • 890
  • 8
  • 28
0

You can Check the font face that it zeros are smaller that the rest of the digit and apply it.