Oli*_*r D 11 android android-layout android-studio react-native
我有一个应用程序是用 React Native 编写的,应用程序中的所有内容都使用“阿拉伯语言和布局”
所以我想强制应用程序也是 RTL 和布局,所以我使用来自 RN 的 I18nManager 来完成它并且它在调试版本中工作正常“当我的移动语言 LTR 或 RTL 工作完美时”
/**
* @format
*/
import {AppRegistry, I18nManager} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
I18nManager.forceRTL(true);
AppRegistry.registerComponent(appName, () => App);
Run Code Online (Sandbox Code Playgroud)
但是当我为 Play 商店发布 apk 版本时,当我的移动语言 RTL“阿拉伯语”布局和其他工作正常时,但是当我的移动语言为 LTR“英语”时,布局会发生变化和所有事情
所以我想强制我的应用程序成为 RTL,无论是移动语言“阿拉伯语还是英语”
小智 11
转到文件
此目录中的 MainApplication.java : android/app/src/main/java/com/YOUR_PROJECT_NAME
并添加此代码
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
sharedI18nUtilInstance.forceRTL(this,true);
sharedI18nUtilInstance.allowRTL(this, true);
Run Code Online (Sandbox Code Playgroud)
到那里的onCreate方法,也不要忘记导入:
import com.facebook.react.modules.i18nmanager.I18nUtil;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3910 次 |
| 最近记录: |