How can I put an icon inside a TextInput in React Native?

前端 未结 9 2130
轻奢々
轻奢々 2020-12-04 19:03

I am thinking of having something like this https://android-arsenal.com/details/1/3941 where you have icon that you press to show password as plaintext, not as dots. However

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 19:16

    You can use combination of View, Icon and TextInput like so:

    
        
         {this.setState({searchString})}}
            underlineColorAndroid="transparent"
        />
    
    

    and use flex-direction for styling

    searchSection: {
        flex: 1,
        flexDirection: 'row',
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#fff',
    },
    searchIcon: {
        padding: 10,
    },
    input: {
        flex: 1,
        paddingTop: 10,
        paddingRight: 10,
        paddingBottom: 10,
        paddingLeft: 0,
        backgroundColor: '#fff',
        color: '#424242',
    },
    

    Icons were taken from "react-native-vector-icons"

提交回复
热议问题