Show layout when soft keyboard opens

我们两清 提交于 2020-02-03 04:30:49

问题


There is a CardView with an EditText and when the keyboard opens, it is placed right below the EditText. But as shown below, the keyboard is too close to the EditText and it is hard to press the "send" button because there is not enough space.

EditText:

EditText with focus:

Is there any way to show the keyboard after the end of the CardView? I saw some similar questions here, but none of them provide a solution that I need. Some answers suggest to set a paddingBotton in EditText, but that is not what I want. I don't want space, I want to show the end of the CardView too.

Note that I don't want to resize the layout, so "adjustResize" is not the solution and I'm already using "adjustPan" in AndroidManifest.xml

<activity
    ...
    android:windowSoftInputMode="adjustPan" />

Any thoughts?


回答1:


If you are using scrollview. you can do one thing is to scroll your scrollview as your requirement

Please refer below code for example

ScrollView sv =(ScrollView)findViewById(R.id.scrl);
sv.scrollTo(0, sv.getBottom());

or 

sv.fullScroll(View.FOCUS_DOWN);

this action you can perform on soft input of Enter key.

There is also one other solution you can hide the suggestion of keyboard by giving

android:inputType="textNoSuggestions"


来源:https://stackoverflow.com/questions/34766973/show-layout-when-soft-keyboard-opens

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