Hide Android/Kotlin Keyboard

Asked

Viewed 63 times

-1

I have a EditText I need you to stay focused, but do not open the keyboard at any time, as it will receive a reading from a Qrcode.

You can do it?

I’ve tried that:

 <androidx.appcompat.widget.AppCompatEditText
        android:id="@+id/txt_focus_qrcode_armazenagem"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginStart="40dp"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="40dp"
        android:background="@drawable/caixa_txt"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:focusable="true"
        android:gravity="center"
        android:hint="Leia o endereço:"
        android:inputType="text"
        android:maxLines="1"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/txt_armazenagem" />
  • Tried to change the android:focusable="true" for android:focusable="false"?

  • Good Afternoon...that from what I saw appensas leaves in focus the text,but still if clicking opens the keyboard

1 answer

2

You can disable using showSoftInputOnFocus, thus staying:

override fun onCreate(savedInstanceState: Bundle?) {
    ........
    val txtFocusQrcodeArmazenagem = findViewById<EditText>(R.id.txt_focus_qrcode_armazenagem)
    txtFocusQrcodeArmazenagem.showSoftInputOnFocus = false
}
  • Bro!!! Too much top worked, now I’ll let him always focus

Browser other questions tagged

You are not signed in. Login or sign up in order to post.