Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Justify spanable Text-view that support RTL Languages

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

like image 769
Hamid Reza Avatar asked Jul 28 '15 11:07

Hamid Reza


1 Answers

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);
        }
like image 142
Javad Shirkhani Avatar answered Nov 15 '22 23:11

Javad Shirkhani