[英]React-native define component height with flexbox
我試圖定義一個具有相同高度的元素列表,但結果是該組件占用了所有可用空間。
這是代碼:
return (
<View style={{flex: 1, flexDirection: 'row', justifyContent: "center"}} key={location.id}>
<Text style={{width: "80%", height: 20}}>{location.name}</Text>
<Button
style={{width: "20%", height: 20}}
title="x"
onPress={() => this.removeLocationFromDevice(location)}
/>
</View>
)
結果如下:
如何確保按鈕和文本元素的高度剛好足以顯示元素,僅此而已?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.