Note - Help needed in maintenance, Please raise PRs for new features and bug fixes, I will review and merge them
dependencyResolutionManagement {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.criminact:OTPView:Tag'
}
<com.noobcode.otpview.OTPView
android:id="@+id/otpView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="#FF000000" //Sets the Text Color and Bottom Line Color
app:borderThickness="6" //Sets the Border Thickness, default is 1 (Integer)
app:otpLength="6" //Sets the length of the OTP, default is 6 (Integer)
app:spaceBetween="20" //Sets the space between the neighbouring Bottom Lines
/>
var otpView = findViewById<OTPView>(R.id.otpView)
otpView.setOTPListener(object : OTPView.OTPListener {
override fun onOTPCompleted(otp: String) {
Toast.makeText(this@MainActivity, "OTP Completed", Toast.LENGTH_LONG).show()
//compare the OTP submitted by user to your generated one. Handle success and failure accordingly
}
}