-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TouchableNativeFeedback's ripples aren't affected by borderRadius on Android 9 #6480
Comments
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 #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 , but it requires its borderless argument to be set to true.
|
@reyesr OMG thank you so much for this! 👍 |
@reyesr IT WORKS!!! Thank you so much buddy!! 🙌 |
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. |
@reyesr thank you..yet it worked for me after I added a View inside TochableNativeFeedback with the same parent style .. like:
|
0.55 + Android Pie = The ripple is not affected by the borderRadius. |
Summary: motivation: there are cases where one'd like to control the radius of the ripple effect that's present on TouchableNativeFeedback - in my case, I want to make sure that both icons and text have the same ripple appearance, but that's currently not possible as far as I can tell. Currently (afaik) the only way to set (upper) ripple limits is by specifying width, height and border radius ( + `overflow: hidden`), and this works well for icons which can usually be bounded by a square, but not for text which can have rectangular shape. This PR adds `rippleRadius` parameter to `SelectableBackground()`, `SelectableBackgroundBorderless()` and `Ripple()` static functions present on `TouchableNativeFeedback`. It can make the ripple smaller but also larger. The result looks like this: added to RNTester: ![SVID_20200219_182027_1](https://user-images.githubusercontent.com/1566403/74858131-147ff380-5345-11ea-8a9e-2730b79eec38.gif) difference from the other ripples: ![SVID_20200209_110918_1](https://user-images.githubusercontent.com/1566403/74109152-4513a080-4b81-11ea-8ec3-bb5862c57244.gif) I'm ofc open to changing the api if needed, but I'm not sure there's much space for manoeuvring. While I was at it, I did a slight refactor of the class into several smaller, more focused methods. It's possible that in some cases, this might help to work around this issue facebook#6480. ## Changelog [Android] [Added] - allow setting custom ripple radius on TouchableNativeFeedback Pull Request resolved: facebook#28009 Test Plan: I tested this locally using RNTester Reviewed By: TheSavior Differential Revision: D20004509 Pulled By: mdvacca fbshipit-source-id: 10de1754d54c17878f36a3859705c1188f15c2a2
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Hi, I don't know if do you have still a problem, but this is how I'm using it ( "react-native": "0.62.2",):
|
Same problem in Pressable =\ |
I tried every possible ways to make it work on Pressable and this problem still persist. Are there any solutions for 0.63.2 yet? |
This still works but it's in the hidden comments now.. |
The |
Is there any update and better solution to this? I've already tried each solution like wrapping the TouchableNativeFeedback in View, setForeground to true, overflow hidden, etc but none of them works. I run it on my phone on Android Pie. |
Have you explicitly set the borderless={false} + adding a view around it with overflow:'hidden' and the same borderRadius as the ripple? |
I did. But in this case, the ripple doesn't appear at all. There's no feedback when pressing the button. This is the code:
|
Ok I found some code in the hidden comments from when I did have problems with this.
This did work for me I think in your example it should be something like <View
style={{borderRadius: 16, overflow: "hidden" }}
>
<TouchableNativeFeedback
onPress={onPress}
style={{borderRadius: 16 }}
useForeground={true}
borderless={false}
background={TouchableNativeFeedback.Ripple(rippleColor, false, 16)}
>
{children}
</TouchableNativeFeedback>
</View>
Maybe also consider using the Pressable component instead of the TouchableNativeFeedback |
This one works for me! Instead of wrapping the Touchable inside View, I wrap the View inside the Touchable. <TouchableNativeFeedback
onPress={onPress}
style={{borderRadius: 16 }}
background={TouchableNativeFeedback.Ripple(rippleColor, false)}
useForeground={true}
>
<View
style={[
{ overflow: "hidden" },
]}
>
{children}
</View>
</TouchableNativeFeedback> |
using |
Closing as @panjiahnh suggestion works. Feel free to open a new issue if this is still happening. |
@safaiyeh did you read my comment? @panjiahnh suggestion is just a workaround and doesn't fix the problem correctly. please reopen this issue. |
Ripple effect has a lot of issues on Android P facebook/react-native#6480 Let's disable it for now and figure out how to fix/workaround it
This solution works for the transparent button, but it does not work for the colored buttons. It looks like it does since the effect is white, but if you try changing it to black or a color, you see the square surrounding the button still. |
So, I tried a solution and it works as expected. The ripple effect works behind the background and it doesn't require useForeground={true} <View style={{ borderRadius: 30, overflow: "hidden"}}>
<TouchableNativeFeedback
background={TouchableNativeFeedback.Ripple("#1D4ED8", false)}
onPress={() => {}}
>
<View style={{ padding: 8, borderRadius: 30 }}>
<Ionicons name="call-outline" size={24} color={"white"} />
</View>
</TouchableNativeFeedback>
</View> Try this out and let me know if it works for you 👯. |
Ripple effect has a lot of issues on Android P facebook/react-native#6480 Let's disable it for now and figure out how to fix/workaround it
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.
The text was updated successfully, but these errors were encountered: