Right to Left in react-native

孤者浪人 提交于 2020-02-03 02:58:28

问题


By using this code(in below),The App has been RTL but location of Right & Left changed(So things must be shown in Right are turned to Left).I did it via tutorial.

ReactNative.I18nManager.allowRTL(true);

And another problem is when Mobile's language is LTR, Location of Images & designs turns into another side(for e.g changes from Right to Left) because App has only one LTR language. Is there any way for showing RTL & LTR like each other??


回答1:


you can use this code :

first :

import { I18nManager } from 'react-native';

second in the App class use this :

constructor(props) {
    super(props);
    I18nManager.forceRTL(true);
}

something like this :

import React, { Component } from 'react';
import { View, I18nManager } from 'react-native';
import { Header } from './src/components/common';
import LoginForm from './src/components/LoginForm';

class App extends Component {

  constructor(props) {
    super(props);
    I18nManager.forceRTL(true);
  }
  render() {
    return (
      <View>
        <Header headerText="Authentication" />
        <LoginForm />
      </View>
    );
  }
}

export default App;


来源:https://stackoverflow.com/questions/43191621/right-to-left-in-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!