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

前端 未结 9 2115
轻奢々
轻奢々 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:36

    //This is an example code to show Image Icon in TextInput// 
    import React, { Component } from 'react';
    //import react in our code.
    
    import { StyleSheet, View, TextInput, Image } from 'react-native';
    //import all the components we are going to use. 
    
    export default class App extends Component<{}> {
      render() {
        return (
          
            
              
    
              
            
             
              
    
              
            
          
        );
      }
    }
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        margin: 10,
      },
    
      SectionStyle: {
        flexDirection: 'row',
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#fff',
        borderWidth: 0.5,
        borderColor: '#000',
        height: 40,
        borderRadius: 5,
        margin: 10,
      },
    
      ImageStyle: {
        padding: 10,
        margin: 5,
        height: 25,
        width: 25,
        resizeMode: 'stretch',
        alignItems: 'center',
      },
    });
    

    Expo

提交回复
热议问题