Git Product home page Git Product logo

android-otpview-pinview's Introduction

Android PinView/OtpView



A custom control to enter a four digit code usually in cases of authentication.

        

Supporting Android PinView/OtpView

Android PinView/OtpView is an independent project with ongoing development and support made possible thanks to donations made by these awesome backers. If you'd like to join them, please consider:

How to integrate into your app?

Integrating the project is simple a refined all you need to do is follow the below steps

Step 1. Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:

allprojects {
  repositories {
    ...
    maven { url "https://jitpack.io" }
  }
}

Step 2. Add the dependency

dependencies {
        implementation 'com.github.mukeshsolanki:android-otpview-pinview:<latest-version>'
}

How to use the library?

Okay seems like you integrated the library in your project but how do you use it? Well its really easy just add the following to your xml design to show the otpview

.....
 <com.mukesh.OtpView
      android:id="@+id/otp_view"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="72dp"
      android:inputType="number"
      android:itemBackground="@color/colorPrimary"
      android:textColor="@android:color/white"
      app:itemCount="6"
      app:lineColor="@color/colorPrimary"
      app:viewType="line"
      />
.....

To get a callback when the user enters the otp make use of OnOtpCompletionListener like wise

 private OtpView otpView;
 otpView = findViewById(R.id.otp_view);
 otpView.setListener(new OnOtpCompletionListener() {
   @Override public void onOtpCompleted(String otp) {

     // do Stuff
     Log.d("onOtpCompleted=>", otp);
   }
 });

That's pretty much it and your all wrapped up.

OtpView Attributes

Attribute Use
app:itemCount sets the length of the otp view
app:itemWidth sets the with of each item inside the otp view
app:itemHeight sets the height of each item inside the otp view
app:itemSpacing sets the space between each item in otp view
app:lineWidth sets the line border width
app:lineColor sets the color to the line border
app:viewType sets the view type of the otp view it can be either rectangle line or none
app:cursorVisible sets the visibility of the cursor
app:cursorColor sets the color of the cursor
app:cursorWidth sets width of the cursor
app:itemBackground sets the background color of each item in the otp view
app:hideLineWhenFilled toggles the line border

Apart from these you can use any property that applies to an EditText.

Author

Maintained by Mukesh Solanki

Contribution

GitHub contributors

License

Copyright 2018 Mukesh Solanki

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.

android-otpview-pinview's People

Contributors

msandeep96 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.