0

我有两个视图,在我的视图中,每个视图中有两个 TextInput 文件,问题是在我的每个文本输入文件之间有很多空间,如何填补它们之间的空白。以下是我的看法:

    <View style={styles.inputContainer}>
          <Image style={styles.inputIcon} source={require('../assets/email.png')}/>
          <TextInput style={styles.inputs}
              placeholder="Email"
              keyboardType="email-address"
              underlineColorAndroid='transparent'
              onChangeText={(email) => this.setState({email})}/>
        </View>
        <View style={styles.inputContainerx}>
          <Image style={styles.inputIcon} source={require('../assets/email.png')}/>
          <TextInput style={styles.inputs}
              placeholder="Password"
              secureTextEntry={true}
              underlineColorAndroid='transparent'
              onChangeText={(password) => this.setState({password})}/>
        </View>

这是样式:

const styles = StyleSheet.create({
    inputs:{
        height:155,
        marginLeft:7,
        borderBottomColor: '#ffff',
    },
      inputContainer: {
        borderBottomColor: '#F5FCFF',
       // backgroundColor: '#FFFFFF',
        borderRadius:50,
        borderBottomWidth: 2,
        width:350,
        height:45,
        marginBottom:180,
        flexDirection: 'row',
        alignItems:'center'
    },
    inputContainerx: {
        borderBottomColor: '#F5FCFF',
       // backgroundColor: '#FFFFFF',
        borderRadius:50,
        borderBottomWidth: 2,
        width:350,
        height:45,
        flexDirection: 'row',
        alignItems:'center',
    },
    inputIcon:{
        width:30,
        height:30,
        marginLeft:15,
        justifyContent: 'center'
      },
});
4

1 回答 1

0

检查下面的例子。希望对你有帮助

import * as React from 'react';
import { Button, View, Text, StyleSheet, TextInput, Image } from 'react-native';

class App extends React.Component {
  render() {
    return (
      <View
        style={{
          flex: 1,
          justifyContent: 'center',
          width: '90%',
          alignSelf: 'center',
        }}>
        <View style={styles.inputContainer}>
          <Image
            style={styles.inputIcon}
            source={{ uri: 'https://reactnative.dev/img/tiny_logo.png' }}
          />
          <TextInput
            style={styles.inputs}
            placeholder="Email"
            keyboardType="email-address"
            underlineColorAndroid="transparent"
            onChangeText={email => this.setState({ email })}
          />
        </View>
        <View style={styles.inputContainerx}>
          <Image
            style={styles.inputIcon}
            source={{ uri: 'https://reactnative.dev/img/tiny_logo.png' }}
          />
          <TextInput
            style={styles.inputs}
            placeholder="Password"
            secureTextEntry={true}
            underlineColorAndroid="transparent"
            onChangeText={password => this.setState({ password })}
          />
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  inputs: {
    flex: 1,
    height: 35,
    paddingHorizontal: 8,
  },
  inputContainer: {
    borderBottomColor: 'gray',
    borderBottomWidth: 1,
    flexDirection: 'row',
    paddingVertical: 10,
    justifyContent: 'center',
  },
  inputContainerx: {
    borderBottomColor: 'gray',
    borderBottomWidth: 1,
    flexDirection: 'row',
    alignItems: 'center',
    paddingVertical: 10,
  },
  inputIcon: {
    width: 30,
    height: 30,
  },
});

export default App;

随意怀疑。

于 2020-03-05T14:24:23.330 回答