alwx / react-native-photo-view

Pinch-to-zoom view for React Native (both iOS and Android)
MIT License
816 stars 436 forks source link

Feature Request: PhotoView as a container (currently works only on iOS) #6

Open szlezak opened 8 years ago

szlezak commented 8 years ago

I trying to put some components inside of the PhotoView.

      <PhotoView
        style={{ height: 300, width: 300 }}
        source={source}
        minimumZoomScale={1}
        maximumZoomScale={3}
      >
        <View>
          .......
        </View>
      </PhotoView>

It works fine on IOS but on Android I getting an error. com.reactnative.photoview.PhotoView cannot be cast to android.view.ViewGroup

alwx commented 8 years ago

@szlezak ability to include views inside PhotoView is neither documented nor possible at this moment.

This feature doesn't work now mostly because on Android side the library uses a custom component that doesn't support this behaviour. But the workaround is possible, of course, and PRs are welcome.

szlezak commented 8 years ago

Thank's for your quick answer.

lenkavon commented 8 years ago

@alwx do you have any tips for workaround?

alwx commented 8 years ago

@lenkavon 1) try to wrap it in another view 2) add position=relative 3) add one more view to your root view and set the position of it manually

it should help, but I haven't tested it

superandrew213 commented 7 years ago

This works:

            <View>
              <PhotoView
                style={styles.image}
                source={source}
                resizeMode={'contain'}
                minimumZoomScale={1}
                maximumZoomScale={3}
                androidScaleType="center"
              />
              <View style={{ position: 'absolute' }}>
                <Text>Hello</Text>
              </View>
            </View>