简体   繁体   English

React Native - 边距或填充在 Android 模拟器上不起作用

[英]React Native - Margin or Padding Not Working on Android Emulator

Below is the code for my component.下面是我的组件的代码。 Problem is that I cannot add any space in between the buttons, only on Android emulator as you can see in the image.问题是我无法在按钮之间添加任何空格,只能在 Android 模拟器上添加,如您在图像中看到的那样。 Right now you see marginBottom but if I replace it with padding, it still does not work.现在你看到了marginBottom但如果我用填充替换它,它仍然不起作用。 Appreciate if anyone has an idea why is this happening.感谢有人知道为什么会发生这种情况。

在此处输入图片说明

import React from 'react';
import { StyleSheet, View} from 'react-native';
import { Button } from 'react-native-elements';

const HomeScreen = ({navigation}) => {

  return(
    <View style={styles.container}>
      <View>
        <Button title="Sign In" onPress={() => navigation.navigate('SignIn')} style={{ marginBottom: 20}}/>
        <Button title="Sign Up" onPress={() => navigation.navigate('SignUp')} />
      </View>
    </View>
  )
}

HomeScreen.navigationOptions = () => {
  return {
    header: () =>  false
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingLeft: 20,
    paddingRight: 20,
    paddingTop: 40,
    backgroundColor: 'white'
  }
});

export default HomeScreen;

As I can understand you are using react-native-elements, and style prop is not vailable on that component, I can see on the documentation try using this prop "buttonStyle" to style the button and if not possible wrap the button around a view,据我所知,您正在使用 react-native-elements,并且样式道具在该组件上不可用,我可以在文档中看到尝试使用此道具“buttonStyle”来设置按钮的样式,如果不可能,将按钮包裹在视图周围,

Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM