If you find Pincode useful, please give it a 🌟
In your build.gradle
:
compile 'mm.mlika.android:pincode2:5.3'
In xml
:
<mlikamohamed.com.pincode.PinCode
xmlns:pin="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:inputType="textVisiblePassword"
android:layout_height="wrap_content"/>
the xml android:inputType="textVisiblePassword"
to remove suggestion
In xml
:
<mlikamohamed.com.pincode.PinCode
xmlns:pin="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:inputType="textVisiblePassword|number"
android:digits="0123456789"
android:layout_height="wrap_content"/>
by default it is 4
In xml
:
pin:boxCount="4"
In java
:
PinCode pinCode = findViewById(R.id.pinCode);
pinCode.setBoxCount(5);
by default 38dp
In xml
:
pin:boxWidthAndHeight="40dp"
In java
:
PinCode pinCode = findViewById(R.id.pinCode);
pinCode.setBoxWidthAndHeight(40); // width and height is 40 pixel
pinCode.setBoxWidthAndHeightDP(40); // width and height is 40 dp
by default the color is grey
In xml
:
pin:boxColor="@color/colorAccent"
In java
:
pinCode.setBoxColor(ContextCompat.getColor(this,R.color.colorAccent));
by default the color is black
In xml
:
pin:highlightedBoxColor="@color/colorPrimary"
In java
:
pinCode.setHighlightedBoxColor(ContextCompat.getColor(this,R.color.colorPrimary));
by default the width is 1 dp
In xml
:
pin:strokeWidth="2dp"
In java
:
pinCode.setStrokeWidth(2); // the width is 2 pixel
pinCode.setStrokeWidthDP(2); // the width is 2 dp
by default the margin between boxes is 10dp
In xml
:
pin:marginBetweenBox="5dp"
In java
:
pinCode.setMarginBetweenBox(10); // 10px
pinCode.setMarginBetweenBoxDp(10); // 10dp
In java
:
PinCode pinCode = findViewById(R.id.pinCode);
pinCode.showText();
pinCode.isTextVisible(); // return true
In java
:
PinCode pinCode = findViewById(R.id.pinCode);
pinCode.hideText();
pinCode.isTextVisible(); // return false
by default the size of the text is 18dp
In xml
:
pin:textSize="30dp"
In java
:
pinCode.setTextSize(17); // text size 17 px
pinCode.setTextSizeDP(17); // text size 17 dp
by default the color is black
In xml
:
pin:boxColor="@color/colorAccent"
In java
:
pinCode.setTextColor(ContextCompat.getColor(this,R.color.colorPrimary));
In xml
:
pin:imageResource="@drawable/icon_google"
In java
:
PinCode pinCode = findViewById(R.id.pinCode);
pinCode.setImageResource(R.drawable.icon_google);
In xml
:
In java
:
PinCode pinCode = findViewById(R.id.pinCode);
pinCode.setTextChangeListener(new PinCode.OnTextChangeListener() {
@Override
public void onTextChanged(String text) {
// this method will be called when text change
}
@Override
public void onAllBoxFilled(String text) {
// this method will be called when all boxes are filled
}
});
Copyright 2017
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.