Reactjs 使用flexDirection时,在react native中出现错误结果

Reactjs 使用flexDirection时,在react native中出现错误结果,reactjs,react-native,flexbox,Reactjs,React Native,Flexbox,我使用以下代码: import React from 'react'; import { Text, View } from 'react-native'; export default class App extends React.Component { render() { return ( <View style={{paddingTop:30,flexDirection:'row',}}> <View style={{back

我使用以下代码:

import React from 'react';
import { Text, View } from 'react-native';

export default class App extends React.Component {
  render() {
    return (
      <View style={{paddingTop:30,flexDirection:'row',}}>
        <View style={{backgroundColor:'red',width:50,height:50}}><Text>1</Text></View>
        <View style={{backgroundColor:'green',width:50,height:50}}><Text>2</Text></View>
      </View>
    );
  }
}
从“React”导入React;
从“react native”导入{Text,View};
导出默认类App扩展React.Component{
render(){
返回(
1.
2.
);
}
}
结果是:

我认为正确的结果应该是:


为什么结果不是我期望的结果?

使用
flex
而不是像这样的高度和宽度:

import React from 'react';
import { Text, View } from 'react-native';

export default class App extends React.Component {
  render() {
    return (
      <View style={{paddingTop:30,flexDirection:'row',}}>
        <View style={{backgroundColor:'red',flex:.5}}><Text>1</Text></View>
        <View style={{backgroundColor:'green',flex:.5}><Text>2</Text></View>
      </View>
    );
  }
}
从“React”导入React;
从“react native”导入{Text,View};
导出默认类App扩展React.Component{
render(){
返回(
1.
2.
);
}
}

您可以根据自己设置flex。这只是一个例子…

我发现了问题,这是因为在Genymotion中设置了位置,我在App.js中使用下面的代码解决了问题

import {I18nManager} from 'react-native'
I18nManager.forceRTL(false)

您的应用程序支持rtl吗?我没有使用,我使用了不同的代码,可能其中一个支持rtl,我如何找到它?签出androidManifest文件
android:supportsRtl=“true”
我在程序中搜索supportsRtl,但是找不到任何东西如果我使用了你的代码,我就正确地获得了左边的红色方块1和右边的绿色方块2。可能您在这里遇到了RTL(或flexDirection)问题。。。您可以通过在组件中写入几个单词来检查它,并查看它是如何呈现的。。。