Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pinball83/Masked-Edittext
Android library contain custom realisation of EditText component for masking and formatting input text
https://github.com/pinball83/Masked-Edittext
android-library input-validation mask widget
Last synced: about 6 hours ago
JSON representation
Android library contain custom realisation of EditText component for masking and formatting input text
- Host: GitHub
- URL: https://github.com/pinball83/Masked-Edittext
- Owner: pinball83
- License: apache-2.0
- Created: 2016-01-11T11:19:54.000Z (almost 9 years ago)
- Default Branch: public
- Last Pushed: 2018-02-12T21:36:46.000Z (almost 7 years ago)
- Last Synced: 2023-11-07T21:33:50.641Z (about 1 year ago)
- Topics: android-library, input-validation, mask, widget
- Language: Java
- Homepage:
- Size: 124 KB
- Stars: 599
- Watchers: 16
- Forks: 98
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-android-ui - https://github.com/pinball83/Masked-Edittext
- awesome-android-ui - https://github.com/pinball83/Masked-Edittext
README
# Masked-Edittext
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.pinball83/masked-edittext/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.pinball83/masked-edittext/) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Masked--Edittext-green.svg?style=true)](https://android-arsenal.com/details/1/3033) [![Android Gems](http://www.android-gems.com/badge/pinball83/Masked-Edittext.svg?branch=master)](http://www.android-gems.com/lib/pinball83/Masked-Edittext)
Masked-Edittext android library EditText widget wrapper add masking and formatting input text functionality.
![Image phone number formatted input](http://g.recordit.co/ROo3bzrX7k.gif)
![Image card number formatted input](http://g.recordit.co/B8IuMTrsYi.gif)
# Install## Maven
com.github.pinball83
masked-edittext
1.0.4
aar
## Gradlecompile 'com.github.pinball83:masked-edittext:1.0.4'
# Usage
### Quick start
You can choose using this widget thought declaring it in layout resource xml
or programmatically create in source file
MaskedEditText maskedEditText = new MaskedEditText.Builder(context)
.mask("8 (***) *** **-**")
.notMaskedSymbol("*")
.icon(R.drawable.ic_account_circle)
.iconCallback(unmaskedText -> { //Icon click callback handler })
.build();### Attributes
MaskedEditText have following attributes#### XML
...
app:mask = "8 (***) *** **-**" //mask
app:notMaskedSymbol = "*" //symbol for mapping allowed placeholders
app:replacementChar = "#" //symbol which will be replaced notMasked symbol e.g. 8 (***) *** **-** will be 8 (###) ### ##-## by default it assign to whitespace
app:deleteChar = "#" //symbol which will be replaced after deleting by default it assign to whitespace
app:format = "[1][2][3] [4][5][6]-[7][8]-[10][9]" //set format of returned data input into MaskedEditText
app:maskIcon = "@drawable/abc_ic_clear_mtrl_alpha" //icon for additional functionality clean input or invoke additional screens
app:maskIconColor = "@color/colorPrimary" //icon tint color
...#### Java
Simple instanceMaskedEditText editText = new MaskedEditText.Builder(context)
.mask("8 (***) *** **-**")
.notMaskedSymbol("*")
.build();; //set mask to "8 (***) *** **-**" and not masked symbol to "*"Text setup and formatting
MaskedEditText editText = new MaskedEditText..Builder(context)
.mask("8 (***) *** **-**")
.notMaskedSymbol("*")
.format("[1][2][3] [4][5][6]-[7][8]-[10][9]")//set format of returned data input into MaskedEditText
.build();
editText.setMaskedText("5551235567"); //set text into widget it will be look like 8 (555) 123 55-67Invocation method getUnmaskedText() return 8 (555) 123 55-76 we swap to last digit
Widget instance with mask, icon button and callback
MaskedEditText editText = new MaskedEditText.Builder(context)
.mask("8 (***) *** **-**")
.notMaskedSymbol("*")
.icon(R.drawable.ic_account_circle)
.iconCallback(unmaskedText -> { //Icon click callback handler })
.build();Getting text
maskedEditText.getUnmaskedText() //return unmasked text
maskedEditText.getText() //return mask and text