1

enter image description here

I use redMadRobot/input-mask library to mask edittext. But I need space between DD / MM / YYYY like in example image and / symbol must be always visible. But I can't do it with this library as I see.

Code :

const val DATE_MASK = "[00]{/}[00]{/}[9900]"

MaskedTextChangedListener.Companion.installOn(
            editText, DATE_MASK, object : MaskedTextChangedListener.ValueListener {
                override fun onTextChanged(
                    maskFilled: Boolean,
                    extractedValue: String,
                    formattedValue: String
                ) {
                    //transactions
                }
            }
        )

Is there any native edittext property to make this desgin or can you suggest another library?

Mehmet Gür
  • 503
  • 7
  • 20
  • `or can you suggest another library` this will get your question closed as seeking recommendations for software libraries. you could always clone that library locally and make it do what you'd like to – a_local_nobody Jan 13 '21 at 08:14
  • @a_local_nobody yes but unfortunately I can't do this. I've been dealing with this for hours. It seems very difficult. – Mehmet Gür Jan 13 '21 at 08:19
  • `yes but unfortunately I can't do this` why not ? – a_local_nobody Jan 13 '21 at 08:23
  • @a_local_nobody because I can't find any property in this library about text aligment like as example image and I don't know any other way to do this. – Mehmet Gür Jan 13 '21 at 08:26
  • i think this design can not be done with only edittext @a_local_nobody – Eric Hollsen Jan 13 '21 at 10:49
  • where did i say that it was possible using only an edittext @EricHollsen ? :) i said OP should clone the library they're using and make changes to it as they need to – a_local_nobody Jan 13 '21 at 10:51
  • 1
    you could try looking at something like [this](https://stackoverflow.com/questions/2912375/masked-input-using-edittext-widget-in-android) but i don't think there's a way of doing this by default no, you'd have to build or code something for it – a_local_nobody Jan 13 '21 at 11:00
  • yeah you didn't say but in this library, one edittext is used. So that's why I think this can not be done with this library. @a_local_nobody – Eric Hollsen Jan 13 '21 at 12:15

1 Answers1

1

Library author here.
input-mask-android is about text formatting, but your question looks more layout-related.

Three EditText components plus two / labels between them might do the trick. setOnEditorActionListener and TextWatcher listeners will help with cursor movement.

Or you could just put a couple of spaces within curly brackets and call it a day: [00]{ / }[00]{ / }[9900]

I'd also suggest reading more about our affine masks, and then use a couple of patterns for the sake of year correctness:

  • [00]{ / }[00]{ / }[00]
  • [00]{ / }[00]{ / }[0000]