android: softkeyboard not shown after return to ac

2019-09-20 19:45发布

My activity is panned in order to make space for soft keyboard(keyboard is visible).

When I leave activity in this state by pressing home button, after return to this activity, layout remains panned, but keyboard is not shown. I'd love keyboard to be shown in this situation, or layout to slide down. Can somebody please help me, how to do that?

I don't want to use android:windowSoftInputMode="stateVisible" because I don't want keyboard to be shown by default.

2条回答
祖国的老花朵
2楼-- · 2019-09-20 20:07

So there must be some problem with fullscreen activities. When I change my activity from fullscreen to for example NoTitleBar, everything works fine.

When using fullscreen activities, the goal is to force redraw/remeasure screen in onRestart method. For this issue with fullscreen activities, I found workaround here

查看更多
虎瘦雄心在
3楼-- · 2019-09-20 20:31

You can try this piece of code when you want to show the keyboard :

((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
.showSoftInput(myEditText, InputMethodManager.SHOW_FORCED);
查看更多
登录 后发表回答