androidreact-native

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?


Solution

  • 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.