反应原生中从右到左 [英] Right to Left in react-native

查看:43
本文介绍了反应原生中从右到左的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过使用此代码(在下面),该应用程序已被 RTL 但位置为 Right &左边改变了(所以必须显示在右边的东西转向左边).我是通过 教程.

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);

另一个问题是当 Mobile 的语言是 LTR 时,图像位置和设计变成了另一面(例如从右到左的变化),因为 App 只有一种 LTR 语言.有什么方法可以显示 RTL &LTR互相喜欢??

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??

推荐答案

你可以使用这个代码:

第一:

import { I18nManager } from 'react-native';

App 类中的第二个使用这个:

second in the App class use this :

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

像这样:

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;

这篇关于反应原生中从右到左的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆