react-native-blur: [Android] Blur not working
I have been trying to get the blur effect to work on Android for a long time now, after finally getting rid of compile and ViewGroup issues, the blur view will not blur anything.
It worked right off the bat in iOS, and continues to work. I am blurring a Google map view under a popup window of sorts. Here’s an excerpt:
<View key={id} style={styles.placeItem}>
<BlurView blurType="light" blurAmount={5} style={styles.placeItemBlur}/>
<ScrollView contentContainerStyle={styles.placeItemContainer}>
<Text style={styles.placeTitleText}>{placeProps.name}</Text>
[...]
</ScrollView>
</View>
This view is itself a child of the map view, which is a child of a scrollable tab view.
As others have suggested, I tried setting backgroundColor: 'transparent' on the ‘thing I want to blur’ (the map, and various other views), with no effect.
Am I missing something obvious? Thanks!
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 2
- Comments: 25 (6 by maintainers)
Thanks guys, thats really helpful. I was working off the readme, which doesn’t include Android usage, nor does it specify being a purely iOS demonstration… I guess I should refer to examples instead.
So are we to understand that you can only blur a single view on Android, and not everything above the blur view, as with iOS? That’s kind of a bummer.
I still can’t get my map view to blur, even after adding the appropriate props and a
viewRef. So I don’t know if this is a limitation of the Android lib or I should try something else? Here is my updated (cross platform) call:and somewhere outside the render() stack, setting state:
Still no blur 😞
I briefly looked around for Android blur views and there are numerous others besides 500px-android-blur… maybe one of them would have features more similar to iOS blur? Android Arsenal link
The obvious thing you’re missing is that you’re using the iOS props, however Android uses different ones.
iOS
Android
I’m having trouble doing this with anything besides blurring an Image however.
@ABleas ah sorry, yes that looks fine. Well, this is the only correct way, to avoid the infinite loop:
I’m not sure why the Google Maps view couldn’t be blurred. This is just a guess, but maybe they do some fancy OpenGL rendering that skips the normal Android views, so the 500px blur library doesn’t work.
I’ll try to add Google Maps to the example project and see if I can figure it out.
I’ve pushed a fix for Android: #173
You can try it out now by adding this to your
package.json:Then make sure you update your Gradle version (at least
1.5.0, but you may as well use2.2.3), and then add those “renderscript” lines. I’ve added these instructions to the README.No problem. I found that documentation for most packages is pretty solid with this library being an exception. I only included this library recently so can’t speak to how it used to work. I’m hoping that using absolute positioning should make it work about the same on both platforms once we have a fix for Android.
As you may have already noticed, the authors are still looking for someone to fix this on Android. Not ideal, but you can use my hack below if you’d like.