css - 滚动视图中的 Flex 内容ContainerStyle React Native
问题描述
我有这个代码:
import React from "react";
import { StyleSheet, Text, View, TextInput, ScrollView, TouchableOpacity } from "react-native";
import EStyleSheet from 'react-native-extended-stylesheet';
EStyleSheet.build()
const Flex = () => {
return (
<View style={styles.mainContainer}>
<ScrollView style={styles.container} contentContainerStyle={styles.content}>
<View style={[styles.fieldEditContainer]}>
<Text style={[styles.fieldName]}>
Email
</Text>
<View
style={[
styles.textInputContainer,
]}>
<TextInput
placeholder="Email"
style={styles.textInput}
/>
</View>
</View>
</ScrollView>
</View>
);
};
const styles = EStyleSheet.create({
mainContainer: {
flex: 1,
},
container: {
flex: 1,
paddingTop: '1rem',
backgroundColor: '#bbded6',
},
content: {
flex: 1,
backgroundColor: '#FFFFFF',
},
textInputContainer: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 10,
height: '3.25rem',
},
textInput: {
flex: 1,
padding: '1rem',
height: '3.25rem',
borderWidth: 2,
borderColor: '#000629',
},
fieldEditContainer: {
marginTop: '0.25rem',
marginBottom: '0.5rem',
width: '100%',
},
fieldName: {
fontWeight: 'bold',
color: '#000629',
fontSize: '1rem',
},
});
export default Flex;
https://snack.expo.io/@rarabibi/supportive-soda
我不明白为什么标题和文字输入被砸成1?当我从内容中删除 flex: 1 时,它们变得正常。我很困惑为什么它与滚动视图的 contentContainerStyle 有关。基本上,我认为我在做的事情就像
父 flex:1 滚动视图 flex:1 滚动视图容器 flex:1 文本视图 flex 1 文本输入 flex 1
为什么他们会被挤成一团?(文本和文本输入)
解决方案
推荐阅读
- c++ - 当对象封装在 const 类中时,如何利用对象的访问器方法?
- python - 检测并删除图像阵列中的零填充?
- amazon-web-services - AWS Lambda - 使用 nextJs 在 2 个环境中部署
- firebase - 如何将复杂的 Firestore 查询卸载到 Firebase Cloud Functions 并在 iOS/Swift 客户端上解析结果?
- sql - 在 SSR 报告中拆分和过滤数据集
- python - 从数组重建图像
- javascript - 使用 audio.srcObject 和 MediaStream 播放来自 ajax 调用的音频
- ruby-on-rails - 在“Ruby On Rails API:身份验证”上重现 Auth0 指令时出错
- laravel - Get the sum of polymorphic relationship models multiplied by pivot
- php - zsh:非法硬件指令 PHP mac os 10.15.6