Search code examples
nativescriptangular2-nativescriptnativescript-angular

How to remove underline in input text while typing and change color of cursor pointer for Android device using nativescript-Angular


I'm developing a native mobile app using nativescript-Angular. I would like text typed by user while filling personal details should not have underline. Also I want to change the color of cursor pointer to different color

enter image description here


Solution

  • Setting autocorrect to false should disable suggestion bar above keyboard as well the underline on word being inputted.

    But for some reason it doesn't seem to work with Google Keyboard (Gboard). A workaround could be setting the input type to visible password,

    HTML

    <TextField (loaded)="onTextFieldLoaded($event)"></TextField>
    

    TS

     // At top of the file
     declare var android;     
    
     ....
    
     onTextFieldLoaded(event) {
        if (event.object.android) {
           event.object.android.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | android.text.InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        }
     }