A library provide an input view present in multiple block style
BlockEditText
Block EditText is a library provide an input view present in multiple block style that common use in TAC or credit card field.
Including In Your Project
If you are a Maven user you can easily include the library by specifying it as
a dependency:
Maven
<dependency>
<groupId>com.infideap.blockedittext</groupId>
<artifactId>block-edittext</artifactId>
<version>0.3.1</version>
<type>pom</type>
</dependency>
Gradle
dependencies {
implementation 'com.infideap.blockedittext:block-edittext:0.3.1'
}
if the gradle unable to sync, you may include this line in project level gradle,
repositories {
maven{
url "https://dl.bintray.com/infideap2/Block-EditText"
}
}
or,
you can include it by download this project and import /blockedittext as module.
How to use
Creating the layout
TAC
<com.infideap.blockedittext.BlockEditText
android:id="@+id/blockEditText_tac"
app:defaultLength="1"
app:numberOfBlock="4"
app:inputType="Integer"
app:hintTextAppearance="@style/TextAppearance.AppCompat.Medium"
app:hint="TAC"
app:textSize="24sp"
android:layout_width="300dp"
app:editTextBackground="@drawable/selector_edittext_round_border"
android:layout_height="wrap_content" />
Credit Card
<com.infideap.blockedittext.BlockEditText
android:id="@+id/blockEditText_visa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:defaultLength="4"
app:hint="Visa/Mastercard"
app:hintTextAppearance="@style/TextAppearance.AppCompat.Medium"
app:inputType="Integer"
app:numberOfBlock="4"
app:text="131321323-13213-21321312" />
Customize
amexEditText.setNumberOfBlock(3);
amexEditText.setDefaultLength(4);
amexEditText.setLengthAt(1,6);
amexEditText.setHint("Amex");
amexEditText.setText("1234567890");
amexEditText.getText();
amexEditText.setTextSize(16);
amexEditText.setHintTextSize(16);
amexEditText.setSeparatorTextSize(16);
amexEditText.setSeparatorCharacter('-');
amexEditText.setSeparatorPadding(8);
amexEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
amexEditText.setTextAppearance(android.support.v7.appcompat.R.style.Base_TextAppearance_AppCompat_Medium);
amexEditText.setHintTextAppearance(android.support.v7.appcompat.R.style.Base_TextAppearance_AppCompat_Medium);
amexEditText.setSeparatorTextAppearance(android.support.v7.appcompat.R.style.Base_TextAppearance_AppCompat_Medium);
amexEditText.setEdiTextBackground(ContextCompat.getDrawable(this, R.drawable.selector_edittext_round_border_line));
amexEditText.setSelection(0);
amexEditText.setShiftPosition(true);
amexEditText.addCardPrefix(CardPrefix.amex(this))
amexEditText.addCardPrefix(CardPrefix.amex(amexDrawable))
amexEditText.addCardPrefix(new CardPrefix(this, R.drawable.ic_amex, "34"))
amexEditText.addCardPrefix(new CardPrefix(amexDrawable, "34"))
Listener
amexEditText.setTextChangedListener(TextWatcher watcher)
amexEditText.setOnCardPrefixListener(OnCardPrefixListener listener)
Contact
For any enquiries, please send an email to tr32010@gmail.com.