3

I know there has been A LOT of talk here regarding justifying text in Android. But Android O just came out and a new feature came out with it, Text Justification. They say use the final JUSTIFICATION_MODE_INTER_WORD included with the TextView class. Along with setJustificationMode(). it does work when I use it with the English language, but it fails to work when I use it with the Hebrew language. I have it set up to:

 <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:justificationMode="inter_word"
            android:text="@string/ahahvaRabba"
            android:textDirection="rtl"
            />

I also tried to put android:gravity="right" but that didnt work either. I cant imagine that google didn't think of using it with other languages.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Edon Freiner
  • 338
  • 2
  • 17
  • It's a new feature, so there are likely to be teething problems. I've tried using it myself and I've discovered that if you set a link movement method (so that tags in your text work) it turns off the justification. I think I'll submit that as a bug report and see what they say... – Stuart Fisher Aug 25 '17 at 11:55
  • Hey, I realized that my mistake was that I was using the feature on a device that was android m and it really wasn't working because of that. Do you know if theres a way to make it work on previous android firmwares? – Edon Freiner Aug 27 '17 at 01:10
  • Mainly for the reason I mentioned, I've fallen back to using the solution provided by twiceYuan for all versions of Android, see here: https://stackoverflow.com/questions/1292575/android-textview-justify-text/43818960#43818960 I did make a couple of tweaks to it though and I don't know if you'll be able to adapt it for rtl text. The other solution that probably makes the most sense is to just use a web view, although for me that seems a bit like using a sledgehammer to crack a nut. – Stuart Fisher Aug 28 '17 at 06:34

0 Answers0