How to hide softkeyboad when activity start in android?

巧了我就是萌 提交于 2019-12-03 04:14:19

问题


I have android app in which one layout contains Linearlayout, ScrollView, TextView, EditView and Button. when I call from one activity to other this activity call and set layout which I have describe.

I would like to know when activity call there is by default EditView selected. and open the softkeyboard. I don't want to open that keyboard when activity start. but I want to open that softkeyboard on touch event of EditView.

How can I do that?


回答1:


In your AndroidManifest.xml:

<activity android:name="com.your.package.ActivityName"
          android:windowSoftInputMode="stateHidden"  />

More details about windowSoftInputMode can be found here.

This setting will hide soft keyboard when user enters new Activity (even if EditText control gains the focus). Soft keyboard will be shown only when user clicks the edit box control.




回答2:


You can hide keyboard by add two lines to the parent view of editText.

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


来源:https://stackoverflow.com/questions/5990966/how-to-hide-softkeyboad-when-activity-start-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!