How to Force React Native app to be just RTL?
go to the file
MainApplication.java in this directory : android/app/src/main/java/com/YOUR_PROJECT_NAME
and add this code
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
sharedI18nUtilInstance.forceRTL(this,true);
sharedI18nUtilInstance.allowRTL(this, true);
to the onCreate method there, also dont forget to import this:
import com.facebook.react.modules.i18nmanager.I18nUtil;
That's because you didn't config the native side in android. Follow these steps:
Open this file:
android > app > src > main > java > com > PACKAGE_NAME > MainApplication.java
Import
I18nUtil
package:import com.facebook.react.modules.i18nmanager.I18nUtil;
Find
onCreate()
function and paste this snippet at the end of function:
public void onCreate() {
...
// Force the app not to change on device locale change
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
sharedI18nUtilInstance.allowRTL(getApplicationContext(), false);
}
Now when you change your device locale, the app layout wouldn't change!