Css flex中的视图:1未扩展到全高,键盘避免视图工作不正常

Css flex中的视图:1未扩展到全高,键盘避免视图工作不正常,css,react-native,flexbox,Css,React Native,Flexbox,我有一个问题,关于一个滚动视图,没有采取完整的高度,仍然 红色边框的视图应该一直向下,因此当键盘不在时,视图的上升幅度不够 这是我的组件代码: <Container> <Header navigation={this.props.navigation} title="Header" /> <ScrollView style={{ flexGrow: 1, borderColor: '#F00

我有一个问题,关于一个滚动视图,没有采取完整的高度,仍然

红色边框的视图应该一直向下,因此当键盘不在时,视图的上升幅度不够

这是我的组件代码:

    <Container>
      <Header navigation={this.props.navigation} title="Header" />
        <ScrollView style={{
          flexGrow: 1,
          borderColor: '#F00',
          borderWidth: 1,
        }}>
          <KeyboardAvoidingView behaviour="padding" keyboardVerticalOffset={50} style={{
            flex: 1,
          }}>
            <InputWithLabel label="1st item" editable={true} onTextChange={this.textChange} />
            <InputWithLabel label="2nd item" editable={true} onTextChange={this.textChange} />
            <InputWithLabel label="3rd item" editable={true} onTextChange={this.textChange} />
            <InputWithLabel label="4th item" editable={true} onTextChange={this.textChange} />
            <InputWithLabel label="5th item" editable={true} onTextChange={this.textChange} />
          </KeyboardAvoidingView>

        </ScrollView>
    </Container>

这是我的根组件,我还使用react导航来显示我的组件:

      <Root>
        <StatusBar translucent={false} barStyle="light-content" />
        <Provider store={store}>
          <AppRoot/>
        </Provider>
      </Root>

我在这里遗漏了什么?

导入{
import {
  Dimensions,  // <--- this
  ...
} from 'react-native'

const { height } = Dimensions.get('window')  // <--- this

<Container>
  <Header navigation={this.props.navigation} title="Header" />
    <ScrollView style={{
      flexGrow: 1,
      borderColor: '#F00',
      borderWidth: 1,
    }}>
      <KeyboardAvoidingView behaviour="padding" keyboardVerticalOffset={50} style={{
        flex: 1,
      }}>
         <View style={{ minHeight: height }}>      // <--- this
           <InputWithLabel label="1st item" editable={true} onTextChange={this.textChange} />
           <InputWithLabel label="2nd item" editable={true} onTextChange={this.textChange} />
           <InputWithLabel label="3rd item" editable={true} onTextChange={this.textChange} />
           <InputWithLabel label="4th item" editable={true} onTextChange={this.textChange} />
           <InputWithLabel label="5th item" editable={true} onTextChange={this.textChange} />
        </View>
      </KeyboardAvoidingView>

    </ScrollView>
</Container>

维度,//我所做的是用键盘AvoidingView增加表单的灵活性,我使用了behavior=“position”,因为其他控件不起作用

例如:

import React from "react";
import Wrapper from "../../components/auth/authBackWrapper";
import SignInTitle from "../../components/auth/signIn/signInTitle";
import SignInForm from "../../components/auth/signIn/signInForm";
import SignInLinks from "../../components/auth/signIn/signInLinks";
import SignInButton from "../../components/auth/signIn/SignInButton";
import { Content } from "../../components/commonStyledComponents/commonStyledComponents";

import styled from "styled-components/native";

const KeyboarAvoid = styled.KeyboardAvoidingView`
    flex: 2.4;
`;

export default ({ }) =>
    <Wrapper>
        <Content p={20}>
            <SignInTitle />
            <KeyboarAvoid behavior='position'>
                <SignInForm />
            </KeyboarAvoid>
            <SignInButton />
            <SignInLinks />
        </Content>
    </Wrapper>
从“React”导入React;
从“../../components/auth/authBackWrapper”导入包装器;
从“../../components/auth/signIn/Signintile”导入Signintile;
从“../../components/auth/signIn/signinfo”导入signinfo;
从“../../components/auth/signIn/SigninLink”导入符号链接;
从“../../components/auth/signIn/SignInButton”导入SignInButton;
从“./../components/commonStyledComponents/commonStyledComponents”导入{Content}”;
从“样式化组件/本机”导入样式化;
const KeyboarAvoid=styled.KeyboardAvoidingView`
弹性:2.4;
`;
导出默认值({})=>

没有其他方法可以实现这一点吗?当flex:1应该以我希望的方式扩展内容时,给内容设置一个固定的高度感觉有点错误。您可以尝试将
contentContainerStyle={{flexGrow:1}
添加到
ScrollView