Scrollable image with pinch-to-zoom in react-native

前端 未结 6 1896
野的像风
野的像风 2020-12-23 12:33

I\'m trying to display an image in my React Native app (Android) and I want to give users an ability to zoom that image in and out. This also requires the image to be scroll

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 13:02

    In my case I have to add images inside Viewpager with Zoom functionality.

    So I have used these two library.

    import ViewPager from '@react-native-community/viewpager'
    import PhotoView from 'react-native-photo-view-ex';
    

    which you can install from.

    npm i @react-native-community/viewpager
    npm i react-native-photo-view-ex
    

    So I have used this code.

    class ResumeView extends React.Component {
    
        render() {
            preivewArray = this.props.showPreview.previewArray
            var pageViews = [];
            for (i = 0; i < preivewArray.length; i++) {
                pageViews.push(
    
                    
    
                );
            }
    
            return (
                
                    {pageViews}
                
            )
        }
    
        pageScroll = (event) => {
            console.log("onPageScroll")
        }
    
    }
    

提交回复
热议问题