我在使用滚动视图和弹性尺寸时遇到了很多麻烦。基本上,应用程序的初始屏幕应显示顶部“横幅”,而底部是“内容”。
内容将包含许多“卡片”,每张卡片都包含信息,用户将能够向下滚动以查看下一张卡片,以及下一张卡片,等等。
但是,flex 属性似乎根本不起作用,我什至无法为“横幅”部分和“内容”部分创建适当的大小。
这是我的代码:
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Image,
ScrollView,
TextInput
{ from 'react-native';
import RestaurantCard from './common/RestaurantCard';
export default class MemberArea extends Component<Props> {
constructor(props){
super(props);
this.state = {
searchText: ''
}
}
render() {
return (
<ScrollView contentContainerStyle = {styles.contentContainer}>
<View style={styles.banner}>
<TextInput style={styles.search}
underlineColorAndroid='rgba(0,0,0,0)'
placeholder="Search for Restaurants"
textAlign= 'center'
textAlignVertical='center'
returnKeyType="search"
/>
</View>
<Text style={styles.dropdown}>
{"What's nearby V"}
</Text>
<View style={styles.cards}>
<RestaurantCard />
</View>
</ScrollView>
);
}
} …Run Code Online (Sandbox Code Playgroud) react-native ×1