使ScrollView大小自动达到最大高度

时间:2017-06-13 23:43:47

标签: react-native

我有一个ScrollView,我希望根据需要增长到一定数量,但似乎总是maxHeight的大小:

<ScrollView style={{flex: 1, maxHeight: "50%"}}><Text>Top</Text></ScrollView>
<View style={{flex: 1}}><Text>Bottom</Text></View>

我想要的是Top视图非常小。如果文本更长,它会根据需要变高,但永远不会高于屏幕的50%。这可能吗?

1 个答案:

答案 0 :(得分:12)

我必须做类似的事情并找到解决方案:

<View style={{maxHeight:"50%"}}>
    <ScrollView style={{flexGrow:0}}>
        <Text>Top</Text>
    </ScrollView>
</View>
<View style={{flex: 1}}><Text>Bottom</Text></View>