react-native-view-shot
react-native-view-shot copied to clipboard
Background transparent not work!
Background transparent not work.
Version & Platform
[email protected]
[email protected]
Platform: Android
Expected behavior
If ViewShot has a transparent background, it should get the background color/image on screenshot.
Actual behavior
Always shot an image with white background.
Steps to reproduce the behavior
If you try this code you can see that the background of image is white instead of gray. What is happening?
<View style={{backgroundColor: 'gray', flex: 1}}>
<Animated.View
{...this.panResponder.panHandlers}
style={[panStyle, styles.circle]}>
<ViewShot ref="viewShot" options={{ format: 'png', result: 'base64' }} style={{backgroundColor: 'transparent', justifyContent: 'center', alignContent: 'center', alignItems: 'center'}}>
<Text>I</Text>
</ViewShot>
</Animated.View>
</View>
The result of base64 images is that:
iVBORw0KGgoAAAANSUhEUgAAAPAAAABMCAYAAABTXTqcAAAABHNCSVQICAgIfAhkiAAAANBJREFUeJzt07ENwlAQBcHDRVEbfVGL64EGnGDZfK00I11y0Ut2BgAAAAAAAAAAAAAAAAAAAAAAANZ6rB7Abd4Hv9fM7P8eAvzuc3DPpYu43LZ6AHCegCFMwBAmYAgTMIQJGMIEDGEChjABQ5iAIUzAECZgCBMwhAkYwgQMYQKGMAFDmIAhTMAQJmAIEzCECRjCBAxhAoYwAUOYgCFMwBAmYAgTMIQJGMIEDGEChjABQ5iAIUzAECZgCBMwhAkYAAAAAAAAAAAAAAAAAAAAbvAFd+EHf8FsvtEAAAAASUVORK5CYII=
As you can see it must has a gray background, but it is white. What Am I doing wrong?
Thanks!
I am ok with format: "png", quality: 1, result: "base64".
did you happen to solve it? same issue
can we get both base64 and png?
Does someone solve the issue?
@Pietro-Putelli try giving background in the styles of viewshot wrapper
Here's an example of code, that doesn't work. https://snack.expo.dev/@pietroputelli/react-native-view-shot
same here, any update?
The same problem, any update?