Dont want soft keyboard to automatically show on l

2019-04-04 12:54发布

问题:

This question already has an answer here:

  • Stop EditText from gaining focus at Activity startup 48 answers

Everytime I open my android app, it automatically focuses the edittext box and the soft keyboard opens up. Is there a way to focus something else on start up so the keyboard doesnt show right away?

回答1:

You can try:

android:windowSoftInputMode="stateHidden"

for your activity in AndroidManifest.xml



回答2:

Add this two lines to you main layout.

android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"


回答3:

Add in your layout definition (in xml file) this following options :

android:focusable="true" android:focusableInTouchMode="true"