如何创建固定覆盖 <View> React Native

kur*_*n26 4 javascript css react-native

我想让灰色框的位置固定,所以当我scrolldownscrollup灰色框保持静止在其位置上时。
在 React Native 中可以做这样的事情吗?

在此输入图像描述


这是我的代码:

<View>
    <ScrollView>
        <View style={styles.continueToPaymentContainer}>
        </View>
    </ScrollView>                
</View>

container: {
    flex: 1,
    // justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#fff'
},
continueToPaymentContainer:{
    width:width,
    height: 100,
    position:'absolute',
    bottom:0,
    backgroundColor: 'grey',
}
Run Code Online (Sandbox Code Playgroud)

Nir*_*inh 5

尝试下面的代码。您只需将视图添加到滚动视图之外即可。

<View>
    <ScrollView>
     // Do your stuff
    </ScrollView>

    <View style={styles.continueToPaymentContainer}>
    </View>              
</View>

container: {
    flex: 1,
    // justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#fff'
},
continueToPaymentContainer:{
    width:width,
    height: 100,
    position:'absolute',
    bottom:0,
    backgroundColor: 'grey',
}
Run Code Online (Sandbox Code Playgroud)