Button 边框半径不适用于按钮
我想用touchableOpacity创建一个边界半径按钮 我试过这种风格:Button 边框半径不适用于按钮,button,react-native,react-native-ios,touchableopacity,Button,React Native,React Native Ios,Touchableopacity,我想用touchableOpacity创建一个边界半径按钮 我试过这种风格: whiteButton : { borderWidth:1, overflow : "hidden", marginTop: "3%", backgroundColor:"white", width:"80%",height:"6%", borderRadius : 20, borderColor:"white", marginBottom:10 } 但
whiteButton : {
borderWidth:1,
overflow : "hidden",
marginTop: "3%",
backgroundColor:"white",
width:"80%",height:"6%",
borderRadius : 20,
borderColor:"white",
marginBottom:10
}
但按钮如下所示:
如果我移除溢出:“隐藏”,它看起来是这样的:
你有什么想法吗
编辑:
在将文本的backgroundColor设置为transparent之后,我得到了与overflow相同的结果:“hidden”,但对于下面的文本,我的文本好像超出了touchableopacity
由于按钮内的文本延伸到按钮的边界,因此边界半径不适用。您需要增大按钮大小或减小文本大小,以便在边界处留出空间,以便实现边界半径。此外,您需要确保文本在按钮内居中(使用
justifyContent
和alignItems
),这样它就不会触及按钮的边界
按钮组件渲染一个可触摸的按钮,并使用满按钮
其父容器的宽度
使用其父级的全宽,这意味着在TouchableOpacity
上添加一个填充。(这是您风格的白按钮
)
对我来说,
padding:2
足以borderRadius:10
好的,问题出在我的代码中。
我没有看到,但我添加了一个视图,touchableopacity被包装在我的视图中
之前:
<View>
<TouchableOpacity onPress={() => {this.sendLoginData()}} style={styles.whiteButton}>
<Text style={{textAlign:"center", fontSize:25, color:"#3b88c3", backgroundColor: 'rgba(0,0,0,0)'}}>S'IDENTIFIER</Text>
</TouchableOpacity>
</View>
{this.sendloginanda()}}style={styles.whiteButton}>
S’标识符
之后:
<TouchableOpacity onPress={() => {this.sendLoginData()}} style={styles.whiteButton}>
<Text style={{textAlign:"center", fontSize:25, color:"#3b88c3", backgroundColor: 'rgba(0,0,0,0)'}}>S'IDENTIFIER</Text>
</TouchableOpacity>
{this.sendloginanda()}}style={styles.whiteButton}>
S’标识符