即使列表中的内容较少,我的ListView容器也会占据100%的高度。
我的代码:
<View style={{ flex: 1, width: '95%', flexDirection: 'row', justifyContent: 'center', alignSelf: 'center' }}>
<Card style={{ width: '95%', alignSelf: 'center', marginTop: 10 }}>
<ListView
dataSource={this.state.dataSource}
renderRow={(item) =>
<CardItem
key={`transaction-${item.data.transactionid}`}
>
// my list code was here
</CardItem>}
ListFooterComponent={this.renderFooter}
onRefresh={this._onRefresh}
refreshing={this.state.refreshing}
onEndReached={this.fetchGoalTransactions}
onEndReachedThreshold={50}
/>
</Card>
答案 0 :(得分:0)
<View style={{flex:1}}>
<View style={{flex:2}}>
//Here is your List View
</View>
<View style={{flex:2}}>
//Its a Empty View
</View>
</View>
为了绑定ListView的高度,可以直接设置视图的高度(不鼓励),也可以确保所有父视图都具有有界高度,因为Lisview使用Scrollview