React Native Nested ScrollView Can`t Scroll on Android Device

后端 未结 5 1313
走了就别回头了
走了就别回头了 2020-12-16 03:06

I have the problem about nested scrollview on Android Device, but IOS OK

How to fix the issue about B scrollview cant scrolling ?

          


        
相关标签:
5条回答
  • 2020-12-16 03:22

    Add "nestedScrollEnabled={true}" property to the internal ScrollView and it will work as expected.

    0 讨论(0)
  • 2020-12-16 03:34

    React-native ScrollView component uses Android ScrollView when you run app in android.

    Android ScrollView doesn't support nested scrolling by default. You need to use NestedScrollView to achieve nested scrolling in android.

    0 讨论(0)
  • 2020-12-16 03:35

    If API 21 as minimum target is an option, you could upgrade to react-native 0.56.x and try the new prop nestedScrollEnabled.

    Note: it is meant to be used in the child scrollview, i.e.

    <ScrollView {...parentProps}>
      <ScrollView {...childProps} nestedScrollEnabled={true}>
      </ScrollView>
    </ScrollView>
    
    0 讨论(0)
  • 2020-12-16 03:37

    In ScrollView, set style of contentContainerStyle to flex: 1:

    <ScrollView>  // A ScrollView
        <View><Text>Hello</Text></View> 
        <View><Text>Hello</Text></View> 
        <View><Text>Hello</Text></View> 
        <View><Text>Hello</Text></View> 
        <View>       
            <ScrollView contentContainerStyle={{flex:1}}> // B ScrollView
                <View><Text>Hello</Text></View>         
                <View><Text>Hello</Text></View>         
                <View><Text>Hello</Text></View>          
                <View><Text>Hello</Text></View>      
            </ScrollView> 
        </View>
    </ScrollView>
    

    It worked for me on android. Let me know if it works for you please.

    0 讨论(0)
  • 2020-12-16 03:38

    https://gist.github.com/ashrithks/8d97f928d92643468a26e29c4d2dbb67

    try the above , expo link:- https://snack.expo.io/S11vIpHA-

    hacky way

    0 讨论(0)
提交回复
热议问题