Abhi
Abhi

Reputation: 111

How to make my edit text type right to left ?

I actually wand to type Arabic,Is it possible ? I am creating an android application.And i am new to it.please help. i tried these code it didn't work.

if(UTILSSessionVariables.LCID==2057)
        {
        setContentView(R.layout.passportdocumentfields);
 LastName.setGravity(Gravity.LEFT);
        }
else if(UTILSSessionVariables.LCID==3801)
        {
            setContentView(R.layout.arabicpassportdetails);

            LastName.setGravity(Gravity.RIGHT);
        } 

Upvotes: 0

Views: 3980

Answers (2)

duggu
duggu

Reputation: 38419

Use a Bidi object to get the information on the position reordering of a bidirectional text, such as Arabic or Hebrew. The natural display ordering of horizontal text in these languages is from right to left, while they order numbers from left to right.

Read the below document :-

http://developer.android.com/reference/java/text/Bidi.html

or

android:textDirection="anyRtl"

http://android-developers.blogspot.in/2013/03/native-rtl-support-in-android-42.html

Upvotes: 1

Gabe Sechan
Gabe Sechan

Reputation: 93561

If the locale of the phone is set to a right to left language, it will do this automatically. At least for all phones 4.0 and higher. Before then there was actually a special patch to the framework that provided that feature that was applied to all phones going to RTL regions, which means it would work on 2.3 phones from those areas, but not on phones without the patch. Of course this means phones without that patch just won't work and there's no real way to fake it, since AFAIK there's no way to tell if the phone has the patch or not.

Upvotes: 0

Related Questions