Android和iOS中的按钮不在同一个位置

问题描述 投票:0回答:1

我的按钮在iOS和Android中不在同一个位置。在Android中,它们位于屏幕的中间位置(这是我所期望的),但在iOS中它们位于屏幕的顶部。

你知道我怎么能把iOS中的按钮放在Android的同一个地方吗?

import { Button } from 'react-native-elements'; 
...
<ImageBackground
    key={`image${i}`}
    source={{uri: image}}
    style={{ width: deviceWidth, justifyContent:'center', alignItems: 'center', flex: 1 }}>
      <View style={{flex: 1}}></View>
      <Text style={{flex: 1}}> {textToDisplayEnglish[i]} </Text>
      <Button
             title={textA[i]}
             style={{flex: 1}}
             type={typeButton[i]}
             onPress={() => this.triggerAction(i)}
      />
      <View style={{flex: 1}}></View>
</ImageBackground>
react-native
1个回答
0
投票

你有太多的flex:1。除非你需要,否则最好避免使用太多。尝试这样的事情:

import { Button } from 'react-native-elements'; 
...
<ImageBackground
    key={`image${i}`}
    source={{uri: image}}
    style={{ width: deviceWidth, justifyContent:'center', alignItems: 'center', flex: 1 }}>

      <Text> {textToDisplayEnglish[i]} </Text>
      <Button
         title={textA[i]}
         type={typeButton[i]}
         onPress={() => this.triggerAction(i)}
      />

</ImageBackground>

希望能帮助到你!

© www.soinside.com 2019 - 2024. All rights reserved.