Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android below 4.2 how to set layoutDirection to be RTL

trying to set the layout elements to be RTL ordered

in 4.2 and above the line: layoutDirection="rtl" and in the manifest: android:supportsRtl="true" is working just fine.

but for below 4.2 its not.

solution anyone ?

like image 327
Nadav Avatar asked Dec 04 '13 13:12

Nadav


People also ask

How do I enable RTL support on android?

On devices running Android 4.4 (API level 19) or higher, you can enable Force RTL layout direction in the on-device developer options. This setting allows you to see text that uses LTR scripts, such as English text, in RTL mode.

How do you make an app RTL?

In your android phone, tap on “Settings” icon. Now tap on developer options and search for “Force RTL layout direction”. Tap on it to enable RTL feature.

How do I disable RTL support on android?

Change all of your app's "left/right" layout properties to new "start/end" equivalents. If you are targeting your app to Android 4.2 (the app's targetSdkVersion or minSdkVersion is 17 or higher), then you should use “start” and “end” instead of “left” and “right”.

What is RTL layout direction?

RTL. Horizontal layout direction is from Right to Left.


2 Answers

Just use ViewCompat using android.support.v4.view to do it.

ViewCompat.setLayoutDirection(findViewById(R.id.my_view), ViewCompat.LAYOUT_DIRECTION_RTL);
like image 69
Aref Bahreini Avatar answered Oct 19 '22 22:10

Aref Bahreini


You won't be able to. It was added to in API Level 17 which is 4.2 so the older versions do not support it.

like image 27
Boardy Avatar answered Oct 20 '22 00:10

Boardy