admin管理员组文章数量:1327843
I'm using react-native-paper
, I would like to make a button with bigger dimensions than normal, as seen in the gif.
I've tried using both height
and padding
, but both don't work properly.
What you see in the gif is the example with padding.
only way to click is in the center, in other places the event does not happen.
Can you give me a hand?
<Button
mode="contained"
labelStyle={{ color: Colors.white }}
style={{ padding: 30 }}
onPress={() => console.log('Pressed')}>
Start
</Button>
I'm using react-native-paper
, I would like to make a button with bigger dimensions than normal, as seen in the gif.
I've tried using both height
and padding
, but both don't work properly.
What you see in the gif is the example with padding.
only way to click is in the center, in other places the event does not happen.
Can you give me a hand?
<Button
mode="contained"
labelStyle={{ color: Colors.white }}
style={{ padding: 30 }}
onPress={() => console.log('Pressed')}>
Start
</Button>
Share
asked Dec 1, 2020 at 21:03
PaulPaul
4,48615 gold badges67 silver badges153 bronze badges
1
- Have you found a solution for the above? – ale917k Commented Oct 26, 2021 at 16:29
2 Answers
Reset to default 8YOU CAN USE
contentStyle
EXAMPLE
<Button
onPress={() => {}}
style={styles.pleteFormButton}
styleText={styles.pleteFormButtonText}
contentStyle={{ // <--- HERE-----
paddingVertical: 10,
}}
preset="outlined"
/>
react-native-papper
has these three props to pass styles
contentStyle Type: StyleProp Style of button's inner content. Use this prop to apply custom height and width and to set the icon on the right with flexDirection: 'row-reverse'.
style Type: StyleProp
labelStyle Type: StyleProp Style for the button text.
View documentation react native paper
you can create a touchablehighlight view around the button and call the same onPress function. something like this:
<TouchableHighlight onPress={() => console.log('Pressed')}>
<View
style={{
height: 70,
width: 110,
borderRadius: 5,
backgroundColor: 'blue',
alignItems: 'center',
justifyContent: 'center',
}}>
<Button
mode="contained"
labelStyle={{ color: 'blue' }}
onPress={() => console.log('Pressed')}>
Start
</Button>
</View>
</TouchableHighlight>
本文标签: javascriptReact native reactnativepaper button with greater heightStack Overflow
版权声明:本文标题:javascript - React native react-native-paper button with greater height - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742220484a2435362.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论