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...
Btw:i need to be able to keep changing properties of the text like colors etc..
Asked
Active
Viewed 140 times
0

Zoe
- 27,060
- 21
- 118
- 148

Jan Ovesny
- 23
- 6
3 Answers
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
-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.

Eduardo Rafael Moraes
- 353
- 4
- 16
-
Hm thank you for try but your solution is not what i was looking for. Doesnt work at all – Jan Ovesny Apr 05 '19 at 04:32
-
This answer doesn't address the problem – Sander Rito Apr 05 '19 at 05:41