16

I need to create a custom text-view in android, first of all it should be justified, then it should support spans and although it should support RTL (Right to Left) languages for ex: Farsi (Persian) ,...

I'm working on this issue for a week! but In fact I stuck In a bad condition because non of available libraries support all these conditions ( Justify, Spanable, RTL)

Do you have any idea?!


I although checked lots of libraries for ex: Link

Community
  • 1
  • 1
Hamid Reza
  • 678
  • 6
  • 21

3 Answers3

0

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.

0

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);
ismail alaoui
  • 4,920
  • 2
  • 12
  • 30
-1

Try adding android:supportsRtl="true" to the <application> element in your manifest file and change your apps "left/right" layout properties to new "start/end".

Refer this link for more information.

rusted brain
  • 1,006
  • 9
  • 23