Android Justify spanable Text-view that support RTL Languages
This code worked for my rtl textView :
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { textView.setJustificationMode(LineBreaker.JUSTIFICATION_MODE_INTER_WORD); }else { textView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); textView.setGravity(Gravity.CENTER_HORIZONTAL); }
You may be able to use this.
The package was created specifically for Right-ToLeft and Justified Textviews, and should support Spannable since it is an extension of TextView.
how to justify span RTL TextView
?
First use this library RTL-TextJustify-Android
Then before setting text to the TextView
:
TextViewEx = myJustifiedTextView; myJustifiedTextView = findViewById...........; finalDescription = ""; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { finalDescription = Html.fromHtml(SpanTextHere, Html.FROM_HTML_MODE_COMPACT).toString(); } else { finalDescription = Html.fromHtml(SpanTextHere).toString(); }myJustifiedTextView.setText(finalDescription,true);