react-native - ScrollView 不显示反应原生的所有内容
问题描述
我有一个包含一些组件的页面。我正在使用滚动视图滚动页面,但某些内容没有显示。这是我的代码:
render() {
const screenHeight = Dimensions.get('window').height
const {currentItem,callsData}=this.state;
return (
<SafeAreaView style={CustomStyles.container}>
<View style={{flexDirection:'row-reverse',padding:10}}>
<View style={{flex:1,justifyContent:'center',flexDirection:'row'}}>
<CustomText style={[CustomStyles.titleWhite]}>Sponsers</CustomText></View>
<TouchableWithoutFeedback onPress={()=>this.props.navigation.goBack()} style={{marginLeft:20,padding:10,}}>
<Icon name='md-arrow-round-back' color={'white'} size={32} />
</TouchableWithoutFeedback>
</View>
<ScrollView contentContainerStyle={{flexGrow:1,height:screenHeight}}>
<View>
{(this.state.done===1)?
<View >
<CustomText style={[CustomStyles.titleWhite,{alignSelf: 'center',}]}> {currentItem.title} </CustomText>
<Image style={{width:'100%',height:'30%',resizeMode:'contain'}} source={{uri:Strings.imageUrl+ currentItem.image1}}/>
<CustomText style={[{color:'white',lineHeight:24}]}>{currentItem.body}</CustomText>
<Video source={{uri:currentItem.videoLink}} // Can be a URL or a local file.
controls={true} // Store reference
onBuffer={this.onBuffer} // Callback when remote video is buffering
onError={this.videoError} // Callback when video cannot be loaded
paused={true}
style={{width:'100%',height:screenHeight/4,}} />
<View style={{flexDirection:'row-reverse'}}>
<Icon />
</View>
<View style={{flexDirection:'row-reverse'}}>
<CustomText style={CustomStyles.whiteTxt}>website: </CustomText>
<CustomText style={{color:Colors.yellow,marginRight: 3}}>{currentItem.website}</CustomText>
</View>
<View style={{flexDirection:'row-reverse'}}>
<CustomText style={CustomStyles.whiteTxt}>Address: </CustomText>
<CustomText style={{color:Colors.yellow,marginRight: 3,}}>{currentItem.address}</CustomText>
</View>
<View style={{flexDirection:'row-reverse'}}>
<CustomText style={[CustomStyles.whiteTxt,]}>Calls: </CustomText>
<FlatList
data={callsData}
contentContainerStyle={{alignItems:'flex-end',marginRight:4}}
keyExtractor={(index)=>index}
renderItem={({item,index})=>
<TouchableOpacity onPress={()=>this.renderCall(index)}>
<CustomText style={{color:Colors.yellow}}>{item}</CustomText></TouchableOpacity>}
/>
<View style={{flex:1}}/>
</View>
</View>
:
<ActivityIndicator/>}</View>
</ScrollView>
</SafeAreaView>
);
}
编辑:这是 CustomStyles.js,颜色文件只包含颜色代码:
import { StyleSheet } from 'react-native';
import Colors from '../Values/Colors'
export default StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'black',
},
titleWhite:{
color:'white',
fontSize:18,margin:5
},
})
我也尝试使用 View 而不是 SafeAreaView 但问题没有解决。底部组件不显示。请帮帮我
解决方案
我认为问题出在 Image 组件高度属性中。我将它从“百分比”更改为这样的数字来自:
height:'30%'
至
height:.3*screenHeight
现在ScrollView
工作正常
推荐阅读
- c# - XPs 文档 OriginX 和 originY 单位
- python - 获取包含来自 5 个链接模型的数据的 django 查询集
- amazon-web-services - 即使 CNAME 别名不正确,注册域能否提供相同的 S3 存储桶?
- java - Agora.io 远程视频是空白的。只有音频作品。本地作品中的一切
- node.js - MEAN 堆栈:使用 express-validator 正确清理用户输入
- if-statement - 突出显示动态范围内单元格值最高的行
- python - 修改可执行python文件问题
- r - ggplot lwd 压倒一切的图例
- .net-core - dotnet core 3.1 应用程序初始化与 heathcheck
- c# - .Net 标准库使用 selenium/cefsharp