TouchableNativeFeedback
A 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 withbackground
property.
Example:
Props
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 propertyborderless
evaluates to true the ripple will render outside of the view bounds (see native actionbar buttons as an example of that behavior). This background type is available on Android API level 21+.
Parameters:
Name and Type
Description
color
string
The ripple color
borderless
boolean
If the ripple can render outside it's bounds
<Button
background={ (Platform.OS === 'android') ? TouchableNativeFeedback.Ripple('#f39c12',true) : null }
style={ styles.buttonStyle }
textStyle={ styles.textStyle }
onPress={ () => {
console.log('world!')
} }>
Hello
</Button>
检测平台如果是Android平台,就设置波纹效果
background={ (Platform.OS === 'android') ? TouchableNativeFeedback.Ripple('#f39c12',true) : null }
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 propertyborderless
evaluates to true the ripple will render outside of the view bounds (see native actionbar buttons as an example of that behavior). This background type is available on Android API level 21+.
Name and Type | Description |
---|---|
color
string
|
The ripple color |
borderless
boolean
|
If the ripple can render outside it's bounds |
<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 }