2

I am trying to render a text input in react-native(android) with and a line below it which am getting from borderBottomWidth property put when am typing there are two lines appearing which is not looking good and couldn't remove it i tried giving underlineColorAndroid='transparent' but didn't work

import * as React from 'react';
import { Text, View, StyleSheet,TextInput } from 'react-native';
import Constants from 'expo-constants';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <TextInput
          autoCapitalize='none'
          autoCorrect={false}
          underlineColorAndroid='rgba(0,0,0,0)'
          style={styles.textInput}
         />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#000',
    padding: 8,
  },
  textInput: {
    paddingVertical: 0,
    marginHorizontal: 10,
    textAlign: 'center',
    height: 18,
    fontSize: 14,
    alignSelf: 'flex-start',
    borderStyle: 'solid',
    borderWidth:0,
    borderBottomWidth: 1,
    color: '#1ac9e8',
    minWidth: 48,
    borderColor: '#1ac9e8',
    fontFamily: 'Monaco'
  }
});

https://snack.expo.io/rylmazFSH

any workarounds ?picture

3 Answers 3

10

Add autoCorrect={false} should remove underline but in some android devices it will not work as described in this link

Try this it is working

autoCorrect={false}
keyboardType="visible-password"

Snack link : https://snack.expo.io/@mehran.khan/underline-android

Sign up to request clarification or add additional context in comments.

1 Comment

in the link you gave also when am commenting the keyboardtype it is still the same but with the keyboardType="visible-password" it is seems to be working strange!!
0
underlineColorAndroid="transparent"

1 Comment

It works for me when I add it but when I go to another screen and come back, I start seeing the underline again
0

Update the style of your textInput. I found the style from snack

  textInput: {
    paddingVertical: 0,
    marginHorizontal: 10,
    textAlign: 'center',
    height: 18,
    fontSize: 14,
    alignSelf: 'flex-start',
    borderStyle: 'solid',
    borderWidth:0,
    color: '#1ac9e8',
    minWidth: 48,
    fontFamily: 'Monaco'
  }



  <TextInput
    underlineColorAndroid="transparent"
        autoCorrect={false}
        keyboardType="visible-password"
style = {styles.textInput}
    />

2 Comments

Actually I need that bottom border line but if see there are 2 lines coming that second line while typing i need to remove
hey it doesn't seem to work can you add a working link ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.