Skip to content

Commit 987ea81

Browse files
Swapnil TiwariSwapnil Tiwari
authored andcommitted
Added readme.MD file for instructions
1 parent ee9738e commit 987ea81

File tree

5 files changed

+82
-2
lines changed

5 files changed

+82
-2
lines changed

app/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
android:clickable="false"
2222
android:cursorVisible="false"
2323
android:digits="0123456789"
24+
android:padding="32dp"
2425
android:inputType="number"
26+
app:oev_primary_color="@android:color/holo_blue_dark"
27+
app:oev_secondary_color="@android:color/holo_orange_light"
2528
android:maxLength="6"
26-
android:padding="8dp"
2729
android:textSize="30sp"
2830
app:layout_constraintTop_toTopOf="parent" />
2931

images/demo.gif

633 KB
Loading

images/demo1.gif

782 KB
Loading

otpedittext2/src/main/java/com/broooapps/otpedittext2/OtpEditText.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected void onDraw(Canvas canvas) {
134134
mCharSize = (availableWidth - (mSpace * (mNumChars - 1))) / mNumChars;
135135
}
136136

137-
mLineSpacing = (float) (getHeight() * .7);
137+
mLineSpacing = (float) (getHeight() * .6);
138138

139139
int startX = getPaddingLeft();
140140
int bottom = getHeight() - getPaddingBottom();

readme.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# OtpEditText
2+
3+
[![](https://jitpack.io/v/swapnil1104/OtpEditText.svg)](https://jitpack.io/#swapnil1104/OtpEditText)
4+
5+
A customised EditText view serving the purpose of taking numeric **One Time Password** from a user.
6+
With stunning animation, and high customizability.
7+
8+
![Demo1](images/demo.gif)
9+
![Demo with other colors](images/demo1.gif)
10+
11+
## Packed with features
12+
- Add custom character limit.
13+
- Use your own color scheme.
14+
- Do not allow user changing cursor position for smooth functioning.
15+
16+
17+
## How to integrate the library in your app?
18+
Step 1: Add it in your root build.gradle at the end of repositories:
19+
20+
```
21+
allprojects {
22+
repositories {
23+
maven { url "https://jitpack.io" }
24+
}
25+
}
26+
```
27+
Step 2. Add the dependency
28+
29+
```
30+
dependencies {
31+
implementation 'com.github.swapnil1104:OtpEditText:0.0.1'
32+
}
33+
```
34+
Step 3. Add OtpEditText to your layout file
35+
36+
```
37+
<com.broooapps.otpedittext2.OtpEditText
38+
android:layout_width="match_parent"
39+
android:layout_height="wrap_content"
40+
android:clickable="false"
41+
android:cursorVisible="false"
42+
android:digits="0123456789"
43+
android:inputType="number"
44+
android:maxLength="6"
45+
android:padding="8dp"
46+
android:textSize="30sp"
47+
app:oev_primary_color="@color/red"
48+
app:oev_secondary_color="@color/light_gray"
49+
/>
50+
```
51+
52+
## How to customize the view.
53+
### Setting desired length for the OTP(One time password code)
54+
55+
To set custom length of the OtpEditText, use
56+
57+
```android:maxLength="{your length}"```
58+
59+
This will automatically generate the right amount of boxes for user to input the code in.
60+
61+
### Setting primary custom color
62+
The primary color signifies the boundary of the box that requires input from user.
63+
To change that use,
64+
65+
```app:oev_primary_color="@color/{your_color}"```
66+
67+
68+
### Setting secondary custom color
69+
The secondary color signifies the boundary of the boxes that do not require input from user.
70+
To change that use,
71+
72+
```app:oev_secondary_color="@color/{your_color}"```
73+
74+
75+
## For optimum usage; Please note.
76+
* Specify `android:textSize` according to your needs.
77+
* Specify `android:padding` according to your needs, there are no paddings drawn by default.
78+
* Specify `android:layout_height` according to the `textSize` you've provided. The view will try to center the text with a vertical biasing of `0.6f`.

0 commit comments

Comments
 (0)