react-native - 适用于 android 的 Scrollable Pinch to Zoom 图像的最佳选择?
问题描述
我设法通过在 React Native 中使用 ScrollView 来实现可滚动的 - 捏缩放 - 图像或视频,如下所示:
<View style={styles.main}>
<ScrollView
ref={scrollRef}
onScroll={(event) => {
if (event.nativeEvent.zoomScale > 1) {
setScrollIsZoomed(true);
} else {
setScrollIsZoomed(false);
}
}}
scrollEventThrottle={2}
showsVerticalScrollIndicator={false}
showsHorizontalScrollIndicator={false}
minimumZoomScale={1}
maximumZoomScale={5}
contentContainerStyle={styles.scrollView}
alwaysBounceVertical={false}
>
{type === 'image' && (
<FastImage
source={{ uri: asset.file }}
style={styles.image}
resizeMode="contain"
/>
)}
{type === 'video' && (
<TouchableWithoutFeedback onPress={muteHandler}>
<Video
muted={isVideoMuted}
source={{
uri: asset.file,
}}
style={styles.video}
repeat={true}
resizeMode="contain"
ignoreSilentSwitch="ignore"
/>
</TouchableWithoutFeedback>
)}
</ScrollView>
但是minimumZoomScale
,maximumZoomScale
道具仅适用于 IOS。这意味着这不适用于android。我看了这么多,我找不到一个合适的解决方案,它具有 ScrollView 如何放大的所有优点。
有什么建议么?
解决方案
推荐阅读
- xcode - XCTest:运行测试失败,X 内有 Cycle;在使用 CocoaPods 和 Carthage 的项目中,建筑可能会产生不可靠的结果
- testing - 在 TestCafé Studio 中测试后自动报告
- xcode - 应用程序无法在 Xcode 12 中的模拟器上启动
- php - 尝试在 laravel 中打开注册表时,我收到一个已修复的错误
- android - 动态 ZXing 扫描仪尺寸 / zxing_scanner_layout
- c# - IIS C#.net web.config:为当前用户获取匹配的“授权”阻止行?
- java - 服务器重新启动后从连接池打开的 LDAP 连接 (UnboundId)
- javascript - 如何在 1 个网站中嵌入 2 个画面仪表板?
- php - Laravel 返回状态 ::35 - SSL 连接错误
- assembly - MASM 中使用的与“_TEXT SEGMENT”等效的 NASM 是什么?