简体   繁体   English

如何在ScrollView内修复屏幕上的视图-React Native

[英]How to fix a View on screen inside a ScrollView - react native

I want to set fixed position on device screen but inside a ScrollView my View shows on bottom of ScrollView . 我想在设备屏幕上设置fixed position ,但是在ScrollView内部,我的View显示在ScrollView底部。

my codes: 我的代码:

<ScrollView>

  <item />
  <item />
  ...

<View style={{
    position: 'absolute', zIndex: 999, bottom: 0, left: 0, width: 50, height: 50,
    borderRadius: 25, backgroundColor: colorConstants.ONE_APP_COLOR, justifyContent: 'center',
    marginLeft: 10, marginBottom: 10
  }}>
    <Text style={{ textAlign: 'center', fontSize: 28, color: '#fff' }}>+</Text>
  </View>

</ScrollView>

Just use this type of structure: 只需使用这种类型的结构:

<View>
   <ScrollView>
   </ScrollView>
   <View>
   </View>
</View>

Your scroll view will have different height, based on number of items, it is an overhead to keep the View in the ScrollView , and probably you will have a lot of bugs and weird behaviors.. 根据项目数,滚动视图的高度将有所不同,将View保留在ScrollView是一项开销,并且可能会有很多错误和怪异行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM