【问题标题】:How to set the ScrollView to fit in react native?如何设置 ScrollView 以适应原生反应?
【发布时间】:2017-11-26 22:14:09
【问题描述】:

如何将 ScrollView 设置为“占用所有剩余空间”而不是设置 height: XXXX ?

 <ScrollView >
         <View style={{
        flex: 1,
        flexDirection: 'column',
        justifyContent: 'space-between',
      }}>
        <View style={{width: 50, height: 50, backgroundColor: 'powderblue'}} />
        <View style={{width: 50, height: 50, backgroundColor: 'skyblue'}} />
        <View style={{width: 50, height: 50, backgroundColor: 'steelblue'}} />
        </View>
           </ScrollView>

【问题讨论】:

  • @JigarShah 我不想使用任何外部库
  • 使用ScrollView 可能无法实现。您需要为所有元素提供height 以覆盖完整的height。您可以使用屏幕高度动态分配 height。这适用于所有屏幕。

标签: android ios react-native flexbox


【解决方案1】:
 <ScrollView contentContainerStyle={{flex:1}}>
      ...
 </ScrollView>

使用 contentContainerStyle 使 scoolView 适应屏幕

【讨论】:

    猜你喜欢
    • 2021-11-06
    • 2017-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-19
    • 1970-01-01
    相关资源
    最近更新 更多