首页 > 解决方案 > 如何创建固定覆盖反应原生

问题描述

我想让灰盒的位置是固定的,所以当我scrolldown或者scrollup灰盒静止不动的时候。
有可能在 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',
}

标签: javascriptcssreact-native

解决方案


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

<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',
}

推荐阅读