React Native android 按钮的波纹效果
TouchableNativeFeedbackA wrapper for making views respond properly to touches (Android only). On Android this component uses native state drawable to display touch feedback. At the moment it only supports having a single View instance as a child node,as it's implemented by replacing that View with another instance of RCTView node with some additional properties set. Background drawable of native feedback touchable can be customized with Example:
renderButton
:
function
(
)
{
return
( <TouchableNativeFeedback onPress
=
{
this
._onPressButton
} background
=
{TouchableNativeFeedback
.
SelectableBackground(
)
}
> <View style
=
{
{width
:
150
, height
:
100
, backgroundColor
:
'red'
}
}
> <Text style
=
{
{margin
:
30
}
}
>Button<
/Text
> <
/View
> <
/TouchableNativeFeedback
>
)
;
}
,
PropsTouchableWithoutFeedback props...backgroundbackgroundPropType Determines the type of background drawable that's going to be used to display feedback. It takes an object with Methods
staticSelectableBackground(0)Creates an object that represents android theme's default background for selectable elements (?android:attr/selectableItemBackground). staticSelectableBackgroundBorderless(0)Creates an object that represent android theme's default background for borderless selectable elements (?android:attr/selectableItemBackgroundBorderless). Available on android API level 21+. staticRipple(color,borderless) Creates an object that represents ripple drawable with specified color (as a string). If property
Parameters:
<Button background={ (Platform.OS === 'android') ? TouchableNativeFeedback.Ripple('#f39c12',true) : null } style={ styles.buttonStyle } textStyle={ styles.textStyle } onPress={ () => { console.log('world!') } }> Hello </Button> background={ (Platform.OS === 'android') ? TouchableNativeFeedback.Ripple('#f39c12',true) : null } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |