1

I need to put a hyphen in the middle of an EditText like this screenshot of WhatsApp verification process.

I saw many questions but they all were about formatting text while user inputs data.

In my case I want it to be there even if there is no text in the EditText and when user starts typing it behaves just like WhatsApp

3 digits before the hyphen and the cursor jumps after the hyphen in 4th digit and puts 3 digits after

the EditText I mean is marked with blue circle

enter image description here

Mohammad
  • 1,185
  • 1
  • 14
  • 26
  • My guess is a custom `TransformationMethod`, but that's only a guess. – CommonsWare Nov 13 '15 at 19:19
  • You could try two EditText views and just add styling around them to get the visual effect that you want. – gMale Nov 13 '15 at 19:38
  • @gmale nice idea but this isn't how it works in WhatsApp. I thought there is some property I don't know or some XML code to do this. – Mohammad Nov 13 '15 at 20:04
  • 1
    @Mohammad how do you know that's not how it works :) If done well, it would be hard to tell. If you're truly curious, one option is to [open up their APK](http://stackoverflow.com/questions/3868768/extracting-android-apk-and-reading-contents-of-xml-file-in-res-layout) and poke around to see if you can find a hint about how they work their magic. – gMale Nov 14 '15 at 18:35
  • @gmale awesome. That's it. I have already their XML files after unpacking apk. How did I forget that. I'll take a look. Thank you a ton for the hint :) – Mohammad Nov 14 '15 at 19:21
  • @Mohammad can you please share how you done that finally ? – Syeda Zunaira Mar 13 '17 at 09:49
  • @SyedaZunairah Unfortunately I didn't figure out how did they did it but the only way is to put 2 text Views in a Linear Layout and use listeners to move to the second text view when character's count reaches the limit you want in the first one. – Mohammad Mar 14 '17 at 23:03

0 Answers0