最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to create fixed overlay <View> React Native - Stack Overflow

programmeradmin6浏览0评论

I want to make the grey box position is fixed, so when I scrolldown or scrollup the grey box is stay still on it position.
Is it possible to do such thing in React Native ?


Here's my code:

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

I want to make the grey box position is fixed, so when I scrolldown or scrollup the grey box is stay still on it position.
Is it possible to do such thing in React Native ?


Here's my code:

<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',
}
Share Improve this question asked May 11, 2018 at 4:54 kurniawan26kurniawan26 8234 gold badges17 silver badges36 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Try below code. You just have to add your view outside the scroll view.

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

I just found it
All I need to do is just put my grey box on the outside of <ScrollView>

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


I hope this will helps for future search

发布评论

评论列表(0)

  1. 暂无评论