|
| 1 | +# OtpEditText |
| 2 | + |
| 3 | +[](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 | + |
| 9 | + |
| 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