0

我是 react native 的新手,我必须设计一个屏幕,当列表变长时,我意识到我的滚动视图在我的代码下方不起作用,请分享建议...谢谢!

<View style={{flex:1}}>
    <ActionBar
      containerStyle={{height:60,alignItems: 'center'}}
      backgroundColor={'#fff'}
      title={'Select Categories'}
      titleStyle={styles.pageTitle}
      onLeftPress={() => goBack()}
      leftIconContainerStyle={{marginTop:22}}
      leftIconName={'back'}
      leftIconImageStyle={{backgroundColor:'#333',height:18,width:18}}
    />
    <Image source={require('../images/bg-login.jpg')}
     style={{position:'absolute',left:0,right:0,top:0,bottom:0}} />
     <ScrollView style={{backgroundColor:'#00000000',position:'absolute',left:0,right:0,top:0,bottom:0}} >
        {views}
    </ScrollView>
    <View style={styles.footerSec}>
        <TouchableOpacity style={styles.nextBtn}
          onPress={()=> {this.props.navigation.navigate('Tutorials',{tutId:this.state.selectedCats})}}>
          <Text style={[styles.btnText, styles.priceText]}>Next</Text>
        </TouchableOpacity>
    </View>
  </View>

这是我的列表代码:

<TouchableOpacity key={itemData[j]._id}
                onPress = {() => {
                  activeItem ? this.removeCat(itemData[j]._id) : this.insertCat(itemData[j]._id)
                }}>

                    <View style={{position:'relative'}}>
                      <LinearGradient colors={activeItem ? ['#cb5fb1', '#f874d8', '#f98bde'] :['#ffb6cf','#ffb6cf','#ffb6cf'] } style={{
                        position: 'absolute',
                        alignItems: 'center',
                        justifyContent:'center',
                        backgroundColor: '#f673d7',
                        width:  armSize,
                        height: armSize,
                        borderRadius: (armSize) / 2,
                        top: topp,
                        left: leftp,
                      }}>
                      <Text style={{
                            color: '#fff',
                            alignSelf:'center',
                            fontSize: RandomNumber,
                            fontWeight: '600',
                            }}>
                        {itemData[j].name}
                      </Text>
                      </LinearGradient>
                    </View>


                </TouchableOpacity>

我在屏幕下方设计,但滚动视图反弹并出现在同一位置......我认为这是因为子位置样式,但它是行中的圆圈所必需的。我无法滚动以下圆圈,这是问题所在。

在此处输入图像描述

4

2 回答 2

2

您可以使用普通 Image 使用position='absolute'放置背景图像并将 ScrollView 的背景颜色不透明度设置为#00000000这意味着它将是透明的

例子

<Image
 source={require('../images/bg-login.jpg')}
 style={{position:'absolute',
 left:0, 
 right:0, 
 top:0,
 bottom:0}} />
 <ScrollView 
  style={{backgroundColor:'#00000000',
  position:'absolute',
  left:0,
  right:0,
  top:0,
  bottom:0}} >
    <View>
        <Text>Some content</Text>
    </View>
</ScrollView>
于 2019-01-18T10:58:35.330 回答
0

For the scroll view issues I used below code and it's working fine everywhere

<ScrollView contentContainerStyle={{ paddingBottom: 120 }}>
---code---

</ScrollView>
于 2019-02-06T14:04:12.223 回答