How to hide Android soft keyboard on EditText

前端 未结 16 1138
长发绾君心
长发绾君心 2020-11-27 14:38

I have an Activity with some EditText fields and some buttons as a convenience for what normally would be used to populate those fields. However when we the user touches on

16条回答
  •  无人及你
    2020-11-27 14:55

    I sometimes use a bit of a trick to do just that. I put an invisible focus holder somewhere on the top of the layout. It would be e.g. like this

     
    

    with this style

    
    

    and then in onResume I would call

        editInvisibleFocusHolder.setInputType(InputType.TYPE_NULL);
        editInvisibleFocusHolder.requestFocus();
    

    That works nicely for me from 1.6 up to 4.x

提交回复
热议问题