React-Native Button style not work

前端 未结 9 1074
傲寒
傲寒 2020-12-24 10:33

Import_this

import {AppRegistry, Text, View, Button, StyleSheet} from \'react-native\';

This my

相关标签:
9条回答
  • 2020-12-24 10:50

    Try This one

    <TouchableOpacity onPress={() => this._onPressAppoimentButton()} style={styles.Btn}>
        <Button title="Order Online" style={styles.Btn} > </Button>
    </TouchableOpacity>
    
    0 讨论(0)
  • 2020-12-24 10:59

    I know this is necro-posting, but I found a real easy way to just add the margin-top and margin-bottom to the button itself without having to build anything else.

    When you create the styles, whether inline or by creating an object to pass, you can do this:

    var buttonStyle = {
       marginTop: "1px",
       marginBottom: "1px"
    }
    

    It seems that adding the quotes around the value makes it work. I don't know if this is because it's a later version of React versus what was posted two years ago, but I know that it works now.

    0 讨论(0)
  • 2020-12-24 11:06

    I had an issue with margin and padding with a Button. I added Button inside a View component and apply your properties to the View.

    <View style={{margin:10}}>
    <Button
      title="Decrypt Data"
      color="orange"
      accessibilityLabel="Tap to Decrypt Data"
      onPress={() => {
        Alert.alert('You tapped the Decrypt button!');
      }}
      />  
    </View>
    
    0 讨论(0)
提交回复
热议问题