Native Base / React Native表单标签图标被切断

问题描述 投票:0回答:2

Iam使用React Native和Native Base开发移动应用程序,同时使用react-native-vector-icons。并且Iam尝试在我的登录表单中添加一些内联标签图标,但由于某种原因,他们不断在右侧切断。

我试图从项目,图标和输入中删除填充,但图标仍然被切断。然后我去改变图标本身的字体大小,但仍然没有做任何事情。

有谁知道这是为什么造成的。我已经上传了我的屏幕图像及其代码。任何有关此事的帮助将不胜感激。这是我在Android LG V30 + App Screenshot上模拟的应用程序图片

 import React, { Component } from "react";
import { Image, View, ImageBackground } from "react-native";
import {
Container,
Header,
Title,
Body,
Content,
Thumbnail,
Card,
CardItem,
Footer,
FooterTab,
Button,
Left,
Right,
Icon,
Form,
Item,
Input,
Text,
InputGroup,
List,
ListItem
} from "native-base";

class LoginScreen extends Component {
render() {
    return (
        <Container>
            <Header>
                <Left>
                    <Button transparent>
                        <Icon
                            name="menu"
                            onPress={() =>
                                this.props.navigation.navigate("DrawerOpen")
                            }
                        />
                    </Button>
                </Left>
                <Body>
                    <Title>Run For A Reason</Title>
                </Body>
                <Right />
            </Header>
            <Content
                contentContainerStyle={{ flex: 1, flexDirection: "column" }}
            >
                <View style={{ flex: 1 }}>
                    <ImageBackground
                        source={require("../../img/background.jpg")}
                        style={{ flex: 1 }}
                    >
                        <View
                            style={{
                                justifyContent: "center",
                                alignItems: "center"
                            }}
                        >
                            <Image
                                source={require("../../img/logo.jpg")}
                                style={styles.logoStyle}
                            />
                        </View>
                        <View
                            style={{
                                paddingTop: 150,
                                paddingLeft: 20,
                                paddingRight: 20
                            }}
                        >
                            <Form style={{ backgroundColor: "white" }}>
                                <Item
                                    style={{
                                        marginLeft: 0,
                                        paddingLeft: 0
                                    }}
                                >
                                    <Icon
                                        style={styles.iconStyles}
                                        name="mail"
                                    />
                                    <Input
                                        style={{ paddingLeft: 0 }}
                                        placeholder="Email"
                                    />
                                </Item>
                                <Item>
                                    <Icon
                                        style={styles.iconStyles}
                                        name="lock"
                                    />
                                    <Input placeholder="Password" />
                                </Item>
                            </Form>
                        </View>
                        <View
                            style={{
                                flexDirection: "row",
                                flex: 1,
                                justifyContent: "center",
                                alignItems: "center"
                            }}
                        >
                            <Button
                                primary
                                style={{ borderRadius: 15, marginTop: 20 }}
                            >
                                <Text>Login</Text>
                            </Button>
                        </View>
                    </ImageBackground>
                </View>
            </Content>
        </Container>
    );
}
}

const styles = {
iconStyles: {
    color: "blue",
    paddingRight: 0
},
logoStyle: {
    paddingTop: 20,
    width: 250,
    height: 200,
    alignItems: "center",
    justifyContent: "center",
    resizeMode: "contain"
}
};
android reactjs react-native icons native-base
2个回答
1
投票

将Icon替换为包含Icon的按钮,并在Button组件上应用您的样式。

<Button iconLeft>
    <Icon name='arrow-back' />
</Button>

0
投票

你能试试吗

  <Form style={{ backgroundColor: 'white' }}>
    <Item>
      <Icon style={styles.iconStyles} name='mail' />
      <Input placeholder='Email' />
    </Item>
    <Item>
      <Icon style={styles.iconStyles} name='lock' />
      <Input placeholder='Password' />
    </Item>
  </Form>

Image

© www.soinside.com 2019 - 2024. All rights reserved.