android - NativeBase 中卡体中的表单不可见

标签 android reactjs react-native native-base

我尝试使用下面的代码(Card 组件内的 Form)

<Card>
   <CardItem header style={{ backgroundColor: 'lightgray' }}>
   <Right>
      <Text>This is Right align text </Text>
   </Right>
   <Badge primary>
      <Text>step 1</Text>
   </Badge>
   </CardItem>
   <CardItem>
      <Body>
         <Text style={{color: 'red'}}>{this.state.error}</Text>
         <Form style={{alignSelf: 'stretch'}}>
         <Item>
            <Label>number:</Label>
            <Input keyboardType="numeric"/>
         </Item>
         <Item>
            <Label>date:</Label>
            <Input />
         </Item>
         <Item>
            <Label>number 2:</Label>
            <Input keyboardType="numeric"/>
         </Item>
         <Item>
            <Label>date 2:</Label>
            <Input />
         </Item>
         <Button success block
            >
            <Text>submit</Text>
            <Icon name='check' size={20} color="#FFFFFF"/>
         </Button>
         </Form>
      </Body>
   </CardItem>
</Card>

但在我的设备 Nexus 7 Tab 中,android 5 页脚不可见。 您对发现问题并解决它有什么建议吗? 我正在使用 NativeBase 2.0.12 和 React-Native 0.42.0

screenshot_2017-03-22-12-00-35

我认为这可能与这个问题有关:https://github.com/GeekyAnts/NativeBase/issues/668

尝试 1: 我稍微更改了代码,并为未出现的 CardItem 添加了 style={{backgroundColor: 'red'}} ,并在外部卡片组件上找到了它。这是我的新代码:

<Card>
   <CardItem header style={{ backgroundColor: 'lightgray' }}>
   <Right>
      <Text>This is Right align text </Text>
   </Right>
   <Badge primary>
      <Text>step 1</Text>
   </Badge>
   </CardItem>
   <CardItem style={{backgroundColor: 'red'}}>
   <Body>
      <Text style={{color: 'red'}}>{this.state.error}</Text>
      <Form style={{alignSelf: 'stretch'}}>
      <Item>
         <Label>number:</Label>
         <Input keyboardType="numeric"/>
      </Item>
      <Item>
         <Label>date:</Label>
         <Input />
      </Item>
      <Item>
         <Label>number 2:</Label>
         <Input keyboardType="numeric"/>
      </Item>
      <Item>
         <Label>date 2:</Label>
         <Input />
      </Item>
      <Button success block
         >
         <Text>submit</Text>
         <Icon name='check' size={20} color="#FFFFFF"/>
      </Button>
      </Form>
   </Body>
   </CardItem>
</Card>

这是新的屏幕截图: screenshot_2017-03-22-18-27-22

当我从 CardItem 中删除 Form 组件时,它会成功呈现,如下所示:

<Card>
   <CardItem header style={{ backgroundColor: 'lightgray' }}>
   <Right>
      <Text>This is Right align text </Text>
   </Right>
   <Badge primary>
      <Text>step 1</Text>
   </Badge>
   </CardItem>
   <CardItem style={{backgroundColor: 'red'}}>
   <Body>
      <Text style={{color: 'red'}}>{this.state.error}</Text>
   </Body>
   </CardItem>
</Card>

screenshot_2017-03-22-18-32-42

为什么我们不能在CardItem中使用Form?这是 Card 组件未记录的限制吗?

最佳答案

默认情况下,您的卡片组件具有弯曲方向列属性,请将其更改为行,以便您可以在第一张卡片下方看到该表单。

`

<Card style={{ flexDirection: 'row' }}>
    <CardItem header style={{ backgroundColor: 'lightgray' }}>
        <Right>
            <Text>This is Right align text </Text>
        </Right>
        <Badge primary>
            <Text>step 1</Text>
        </Badge>
    </CardItem>
    <CardItem style={{ backgroundColor: 'red' }}>
        <Body>
            <Text style={{ color: 'red' }}>{this.state.error}</Text>
            <Form style={{ alignSelf: 'stretch' }}>
                <Item>
                    <Label>number:</Label>
                    <Input keyboardType="numeric" />
                </Item>
                <Item>
                    <Label>date:</Label>
                    <Input />
                </Item>
                <Item>
                    <Label>number 2:</Label>
                    <Input keyboardType="numeric" />
                </Item>
                <Item>
                    <Label>date 2:</Label>
                    <Input />
                </Item>
                <Button success block
                >
                    <Text>submit</Text>
                    <Icon name='check' size={20} color="#FFFFFF" />
                </Button>
            </Form>
        </Body>
    </CardItem>
</Card>

`

关于android - NativeBase 中卡体中的表单不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42954610/

相关文章:

java - GSON 非法状态异常 : Expected BEGIN_OBJECT but was BEGIN_ARRAY

java - 在方法外部使用变量值

javascript - 将 "Route children"和 "cloneElement"转换为 RouterV4

react-native - 在 React Native Library 中,如何获取 ios 当前的 UIViewController

android - 在javascript中获取可用字体列表作为组合框

android - 如果 Android Activity/Application/Service 的上下文属于同一个应用程序,它们是同一个对象吗?

javascript - Gatsby : Display 404 page if route doesn't exist

reactjs - 如何传递带有默认值的参数?

linux - 如何启用 Android 虚拟设备 (AVD)

react-native - 在 iOS 上未收到本地预定通知