TouchableNativeFeedback's ripples aren't affected by borderRadius on Android 9
This is a bit of a problem when creating buttons with borderRadius and TouchableNativeFeedback, and the ripples extend out. I'm not an expert but I suppose setNativeBackground needs to get the corner radius when making the mask for the RippleDrawable and setBorderRadius may need to remake the background drawable somehow.
Attached the following images to represent graphically what is proposed

Images were taken from Michael Evans Blog - Android Ripples With Rounded Corners
It's supposed to be implemented in https://github.com/facebook/react-native/pull/6515 but I can't make it work :/
I realize that PR got reverted
FWIW, as of 0.30, the ripple effect works with respect to the borderRadius of its parent
<View style={{borderRadius: 24, backgroundColor: '#F66', width: 48,height: 48}}> <TouchableNativeFeedback background={TouchableNativeFeedback.Ripple('#AAF', true)}> [snip] </TouchableNativeFeedback> </View>
If this is the intented effect, it should probably be made explicit, and added to the documentation. It it's a side effect (no pun intented), #6515 still makes sense.
@reyesr OMG thank you so much for this! 👍
@reyesr IT WORKS!!! Thank you so much buddy!! :raised_hands:
Looks like this is resolved. Feel free to open a new issue if you're still having troubles with it
Re-opening since this issue has re-surfaced on Android P.
Just to illustrate from Android P:

@reyesr thank you..yet it worked for me after I added a View inside TochableNativeFeedback with the same parent style .. like:
<View style={{ borderRadius: 20, backgroundColor: '#2f2', width: 80, height: 80 }}>
<TouchableNativeFeedback background={TouchableNativeFeedback.Ripple('#AAF', true)}>
<View style={{ borderRadius: 20, backgroundColor: '#2f2', width: 80, height: 80 }}>
<Text> test button </Text>
</View>
</TouchableNativeFeedback>
</View>
0.55 + Android Pie = The ripple is not affected by the borderRadius. Tried all the variations (View from outside, View from inside, both).
This issue was never solved, the solution given in a comment above is a hack.
Any updates on the issue?
<View style={{ borderRadius: 5, overflow: 'hidden' }}>
<TouchableNativeFeedback onPress={() => {}} background={TouchableNativeFeedback.Ripple('red')}>
{'CLICK CLICK'}
</TouchableNativeFeedback>
</View>
You guys should try to wrap your TouchableNativeFeedback in a view with a border-radius and an hidden overflow.
@balthazar , wrapping the touchable hides the effect of borderless ripple. This is undesired in Floating Action Buttons components.
@aMarCruz I'm not talking about borderless ripples here, as my example shows.
I've been trying the button issue with https://github.com/kmagiera/react-native-gesture-handler. Looks like it works correctly using the buttons from the library on Android P:

For me it works when I set in TouchableRipple.js the useForeground true + borderless false
disabled={disabled}
useForeground={true}
background={
background != null
? background
: TouchableNativeFeedback.Ripple(calculatedRippleColor, false)
}
Also on e.g. the FAB its needs an overflow: 'hidden' style. Works for me on both iOS and Android!
touchable: {
borderRadius: 28,
overflow: 'hidden',
},
I'm running the latest Android (9 Pie)
Thanks @RichardLindhout
If anyone is still experiencing this on the latest release please submit a new issue
@rickhanlonii That's a workaround which we can't use if oveflow: hidden is not desirable. The behavior is still different between Android versions and buggy.