新版本的React Native已经发布了对RTL设备的支持:https://facebook.github.io/react-native/blog/2016/08/19/right-to-left-support-for-react-native-apps.html 然而,似乎在RTL安卓设备中,RTL布局是强制的,并且没有办法改变它,所以现在所有的应用程序都被破坏了RTL设备。如何强制我的应用程序使用LTR?
我设法通过添加到MainApplication.java
来解决这个问题:
import com.facebook.react.modules.i18nmanager.I18nUtil;
public class MainApplication extends Application implements ReactApplication {
@Override
public void onCreate() {
super.onCreate();
// FORCE LTR
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
sharedI18nUtilInstance.allowRTL(getApplicationContext(), false);
....
}
}
在manifest.xml文件中,将android:supportsRtl="false"
添加到您的应用程序标记中
如果你正在使用世博会
import { I18nManager} from 'react-native';
I18nManager.allowRTL(false);
export default class <className> extends Component {
}