Apply/remove mask from text with some utilities out-of-box for Android EditText
- Include maven central as repository
- Import project dependency
dependencies {
⋮
implementation "br.dev.dig.text.mask:text-mask:${lastest_version}"
// FOR ANDROID:
implementation "br.dev.dig.text.mask:text-mask-android:${lastest_version}"
⋮
}
- Create a
TextMask
instance
final TextMask mask = new TextMask("#### #### #### ####");
final CharSequence formatted = mask.format("12345678");
final CharSequence raw = mask.unformat("1234 5678 1234 5678");
- Create a
TextMaskTextWatcher
with anEditText
and aTextMask
, and apply (insert) intoEditText
.
final TextMaskTextWatcher watcher = new TextMaskTextWatcher(editText, new TextMask("#### #### #### ####")).insert();
- You can use and re-dist freely.
- You can also modify, but only for yourself.
- You can use it as a part of your project, but without modifications in this project.