0

How do I create a Custom edit text UI like this where hint won't disappear when I type the input. So the basic idea is when I am typing the credit card number the X digit should get replaced with the number I have typed. Also, the user is not allowed to enter digit in any order rather he can only enter the input in a sequential manner here's the screenshot for reference.

Edit: So I was thinking to add 16 different edit text where pressing backspace would take user to previous edit text and only first edit-text would be focusable has anyone has a better solution for this.

enter image description here

pratham kesarkar
  • 3,770
  • 3
  • 19
  • 29

1 Answers1

0

Try to set the XXX as the text, not as a hint, and use Spannable to set the color of the text, if X -> color grey, if number -> color white

How to set different colors for edittext using spanable: edittext with different color in android

For skipping where the spaces are - use 4 edittexts and set focus to navigate to the next edittext

Sharone Lev
  • 791
  • 7
  • 15
  • What about user cannot enter text anywhere in between. If you set the text to XXXX user can enter the text anywhere in between – pratham kesarkar Nov 11 '19 at 09:17
  • 1
    set an OnFocusListener, if user taps a character focus will always go to start of first edittext – Sharone Lev Nov 11 '19 at 09:19
  • @prathamkesarkar did you manage to do this? I actually just posted a tutorial for the multiple edittexts approach which might assist you https://medium.com/@Lev_Sharone/create-your-own-customized-pin-code-layout-in-3-simple-steps-e36d560689f8 – Sharone Lev Nov 19 '19 at 06:37
  • actually I did with some hacks – pratham kesarkar Jun 26 '20 at 12:23