mukeshsolanki / android-otpview-pinview

A custom view to enter otp of different sizes used usually in cases of authentication.
MIT License
707 stars 207 forks source link

android edittext cursor always showing at 2nd box for 6 digit otp #116

Closed manik123gupta closed 2 years ago

manik123gupta commented 3 years ago

Subject of the issue

android edittext cursor always showing at 2nd box for 6 digit otp

Steps to reproduce

click on otp box after filling all digits (6 digit otp box)

Expected behaviour

android edittext cursor always should show at tapped position

Actual behaviour

android edittext cursor always showing at 2nd box for 6 digit otp

vetriselvi-i2i commented 3 years ago

Yes, I'm also facing the same issue. Is there any workaround for it? or How to disable the system cursor?

azizanhakim commented 3 years ago

i am looking for the workaround for it too.

bgraknd commented 3 years ago

@vetriselvi-i2i @azizanhakim //Create shape empty

 <?xml version="1.0" encoding="UTF-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle" >

 <size
    android:height="0dp"
    android:width="0dp" />

 </shape>

and just use this in edittext android:textSelectHandle="@drawable/your_empty_shape"

***It work for me

I have the same problem. I tried this but didn't work.

anunkwp commented 3 years ago

@bgraknd //This is new solution for me use Kotlin

private fun focusAndShowKeyboard(context: Context, editText: EditText) {
        editText.requestFocus()
        val imm: InputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY)
    }
 cvvView.apply {
            setOnTouchListener { view, motionEvent ->
                focusAndShowKeyboard(view.context, this)
                true
            }
}
alierdogan7 commented 3 years ago
<com.mukesh.OtpView
                android:id="@+id/otp_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:cursorVisible="false"
                android:inputType="number"
                android:textSelectHandle="@android:color/transparent"
                app:OtpCursorColor="@color/indigo"
                app:OtpHideLineWhenFilled="false"
                app:OtpItemCount="6" />

Add these two lines in your XML layout:

android:cursorVisible="false"
android:textSelectHandle="@android:color/transparent"
mukeshsolanki commented 2 years ago

Please check the latest version of the lib