如何在 ScrollView 内修复屏幕上的视图 - 反应原生 [英] How to fix a View on screen inside a ScrollView - react native

查看:25
本文介绍了如何在 ScrollView 内修复屏幕上的视图 - 反应原生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在设备屏幕上设置 fixed position 但在 ScrollView 内,我的 View 显示在 ScrollView 的底部>.

I want to set fixed position on device screen but inside a ScrollView my View shows on bottom of ScrollView.

我的代码:

<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>

推荐答案

就用这种结构:

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

您的滚动视图将具有不同的高度,基于项目的数量,将 View 保留在 ScrollView 中是一种开销,并且您可能会有很多错误和奇怪的行为..

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..

这篇关于如何在 ScrollView 内修复屏幕上的视图 - 反应原生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆