mukeshsolanki / android-otpview-pinview

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

OtpView is not gaining focus and not showing keypad #125

Closed arunp1024 closed 2 years ago

arunp1024 commented 3 years ago
    <com.mukesh.OtpView
        android:id="@+id/otp_view"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:inputType="number"
        android:layout_marginTop="@dimen/margin_32"
        android:textColor="@android:color/white"
        app:OtpItemWidth="40dp"
        app:OtpItemCount="6"
        app:OtpLineColor="@color/white"
        app:OtpViewType="none"
        android:clickable="true"
        android:textIsSelectable="true"
        android:focusable="true"
        android:cursorVisible="true"
        android:focusableInTouchMode="true"
        app:layout_constraintStart_toStartOf="@id/guideline2"
        app:layout_constraintTop_toBottomOf="@+id/enter_otp_txt"
        app:layout_constraintEnd_toEndOf="@+id/guideline3"
        />

I'm using above xml and below style

But otpview is not getting focus.

In some devices its not working and in some devices its working Working in Mi A2. Not working in Nokia 7.1 and One plus 5T

Expected to show keyboard with otpview focused in all devices

gokul1408 commented 3 years ago

Add otpview style in the AppTheme

Sushantlama commented 3 years ago

@gokul1408 Thanks it worked well

AdieOlami commented 3 years ago

I am experiencing this and I have done what was specified here.

arzakmiftakhul commented 3 years ago

add android:focusableInTouchMode="true" on OtpView

todojean commented 3 years ago

Ao colocar o codigo abaixo no "on code sent" o teclado aparece mas o OTP view não recebe o foco. InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0); binding.otpView.requestFocus();

Não Achei a solução ainda.

haissamtariqzaman commented 3 years ago

android:focusableInTouchMode="true"

Thankyou so much

absolute-vijju commented 2 years ago

1. Add this property (android:windowSoftInputMode="stateVisible") into your manifest's activity tag like this:

<activity android:name=".ui.AuthActivity" android:exported="true" android:screenOrientation="portrait" android:windowSoftInputMode="stateVisible" />

2. Add this line into your Activity class when you want to open keyboard:

mBinding.otpView.requestFocus()

That's all you need to do :)