Vik*_*rya 9 reactjs react-native react-native-android react-native-ios react-component
在参考了这个文档可按下文档后,我正在使用可按下作为按钮
现在我想为按钮添加涟漪效果,但它无法正常工作。
<Pressable
android_ripple={{color: 'red', borderless: false}}
style={{backgroundColor: 'blue',borderRadius : 10}}>
<Text style={{alignSelf: 'center'}}>Button</Text>
</Pressable>
Run Code Online (Sandbox Code Playgroud)
如果按钮具有半径,则波纹效果没有边框半径。波纹效果角超出弯曲半径看起来很尴尬。
Vik*_*rya 10
没有什么对我有用,所以我自己解决了这个问题。
<View style={styles.buttonView}>
<Pressable
onPress={() => {}}
android_ripple={{color: 'black', borderless: true}}
style={styles.loginButton}>
<Text style={styles.buttonText}>Login</Text>
</Pressable>
</View>
Run Code Online (Sandbox Code Playgroud)
buttonView: {
alignSelf: 'stretch',
justifyContent: 'center',
borderRadius: 10,
elevation: 25,
margin: 10,
},
loginButton: {
height: 50,
backgroundColor: '#0f4c75',
padding: 10,
alignItems: 'center',
justifyContent: 'center',
},
buttonText: {
color: 'white',
fontSize: 16,
textTransform: 'uppercase',
fontFamily: 'sans-serif-light',
},
Run Code Online (Sandbox Code Playgroud)
小智 9
您可以将 pressable 包装到 View 中并将 borderRadius:10 和 overflow:'hidden' 传递给 View 样式。
<View style={{ borderRadius: 10, overflow: 'hidden' }}>
<Pressable
android_ripple={{ color: 'red', borderless: false, }}
style={{ backgroundColor: 'blue', borderRadius: 10 }}>
<Text style={{ alignSelf: 'center' }}>Button</Text>
</Pressable>
</View>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3770 次 |
| 最近记录: |