0

Does anyone know how to aligne two numbers on one line in android textview so one is aligned left and second one right? Gravity doesnt help neither html.format...enter image description here Btw:i need to be able to keep changing properties of the text like colors etc..

Zoe
  • 27,060
  • 21
  • 118
  • 148
Jan Ovesny
  • 23
  • 6

3 Answers3

0

I dont think this is supported by android. Maybe using justify could do it, but it only works on Oreo and beyond

https://stackoverflow.com/a/1293541/3885877

Else I would try a custom text view, where the 2 texts are aligned to the sides.

But I don't think you can achieve this very easy.

Sander Rito
  • 396
  • 2
  • 8
0

So i solve it by adding second textview

Jan Ovesny
  • 23
  • 6
-1

You could use dynamic strings with strings.value for this. For example: in strings.xml add this:

<string name="left_and_right_alignment">%1$s %2$s</string>

and in your class you can use:

getContext().getResources().getString(R.string.left_and_right_alignment, "left", "right")

Hope this helps.