pfu*_*t75 5 css ios flexbox react-native react-native-flexbox
我有一个简单的 View,它有两个孩子,另一个 View 和一个 ScrollView。ScrollView 应该比同级别的 View 高 5 倍,使用 flexbox。
<View style={{ flex: 1}}>
<View style={{flex: 1, backgroundColor: 'powderblue'}}>
<Text>Add new stuff</Text>
<Button title="Browse Gallery" onPress={ openGallery } />
</View>
<ScrollView style={{flex: 5, backgroundColor: 'skyblue'}}>
<Text style={{ fontSize: 100}}>Scroll me plz</Text>
<Text style={{ fontSize: 100}}>Scroll me plz</Text>
</ScrollView>
</View>
Run Code Online (Sandbox Code Playgroud)
顺便说一句,使用第二个 View 而不是 ScrollView 效果很好!
任何想法如何使用 ScrollView 实现 1:5 的比例?
ScrollView 是一个不继承flex
. 您想要做的是将 ScrollView 包装在一个 View 中,这将创建您想要的弹性比率。
<View style={{flex: 1}}>
<View style={{flex: 1, backgroundColor: 'powderblue'}}>
<Text>Add new stuff</Text>
<Button title="Browse Gallery" onPress={ openGallery } />
</View>
<View style={{flex: 5}}>
<ScrollView style={{backgroundColor: 'skyblue'}}>
<Text style={{ fontSize: 100}}>Scroll me plz</Text>
<Text style={{ fontSize: 100}}>Scroll me plz</Text>
</ScrollView>
</View>
</View>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5336 次 |
最近记录: |