I am facing one issue with aligning text vertically center for button but it remains slightly lower then exact center.
I found includeFontPadding
from documentation with suggesting some discrepancies with some third party font.
Font looks proper in iOS devices but it is not properly centered with Android.
https://facebook.github.io/react-native/docs/text-style-props#includefontpadding
Set to false to remove extra font padding intended to make space for certain ascenders / descenders. With some fonts, this padding can make text look slightly misaligned when centered vertically. For best results also set textAlignVertical to center. Default is true.
<Button
style={[style.button]} block >
<Text>Setup Now</Text>
</Button>
Style for button:
export default {
button: {
elevation: null,
shadowColor: null,
shadowOffset: null,
shadowOpacity: null,
shadowRadius: null
}
}
Instead of using a Text component inside a Button Component. Use the prop "title" as defined in the Button Documentation:
https://facebook.github.io/react-native/docs/button.html
So your code will be
<Button
style={[style.button]} title="Setup Now" block >
</Button>
If you are using react native default button then react native default button does not support style properties and also Instead of using a Text component inside a Button Component. Use the properties "title" as defined in the official Documentation for that please refer the below link
https://facebook.github.io/react-native/docs/button.html
Also react native provide various options for button for your customisation button and as per your use for that please refer the below link
https://facebook.github.io/react-native/docs/handling-touches
Please try this below solution, may help for your issue.
<TouchableOpacity
activeOpacity={.5}
style={styles.buttonStyle}>
<Text style={styles.textStyle}>Setup Now</Text>
</TouchableOpacity>
buttonStyle: {
padding: 14,
backgroundColor: 'red',
borderRadius: 6,
},
textStyle: {
color: 'white',
textAlign: 'center',
fontWeight: 'bold',
fontSize: 16,
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With