如何在 React Native 中将视图的方向属性设置为 RTL

2023-12-13

如何设置a的方向属性View在反应本机......类似:

<View direction="rtl" />

OR

如何强制整个应用程序的方向从右到左......无论当前的设备语言如何使我的应用程序 RTL 就绪


我通过调用解决了这个问题forceRTL在 MainApplication.java 中,如下所示:

主应用程序.java导入 com.facebook.react.modules.i18nmanager.I18nUtil;

 @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);

    I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
    sharedI18nUtilInstance.forceRTL(this,true);
    sharedI18nUtilInstance.allowRTL(this, true);
  }

AndroidManifest.xml

<Application
...
android:supportsRtl="true"
...
/>

导致调用forceRTLApp.js确实需要重新启动应用程序才能工作。

I18nManager.forceRTL(true); // Work on second-load of the app

现在当我设置flexDirection: 'row'它将是从右到左

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 React Native 中将视图的方向属性设置为 RTL 的相关文章

随机推荐