Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force RTL on LTR devices

The title says it all. I found a couple of ways to set the application's default layout to RTL using Facebook's I18nManager, but it does that only on second app launch.

code example: I18nManager.forceRTL(true)

I do not want to give users the ability to change languages because the application itself is in Arabic. I've searched everywhere but all talk about how to support RTL and not actually use it as the default layout.

Is there a way to achieve this with I18nManager or do I have to do a couple of changes to my native code?

like image 355
Ray Avatar asked May 26 '17 23:05

Ray


People also ask

How do I force RTL on android?

To force right-to-left layouts on your Android device you need to open Settings, and access the Developer options menu (if developer options aren't enabled, here's how to do it). Once you've accessed the menu, scroll down to find the “Force RTL layout direction” tab. Tap on it to activate the option, and you're done.

What is Force RTL layout in developer options?

Force RTL layout direction: Forces screen layout direction to be from right to left (RTL) or from left to right (default). Window animation scale: Sets the window animation playback speed so you can check its performance at different speeds. A lower scale results in a faster speed.


1 Answers

add this line of code to the most top of the onCreate method (before super and setContentView) of all of your activities:

getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);

and sure that you have supportRtl equal to True in manifest.

like image 99
Parazok Avatar answered Sep 21 '22 04:09

Parazok