软键盘打开时显示布局 [英] Show layout when soft keyboard opens
问题描述
有一个 CardView
与的EditText
和键盘打开时,它被放在右下面的的EditText
。但是,如下所示,键盘是太靠近的EditText和很难preSS的发送按钮,因为没有足够的空间。
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:
有什么办法来显示CardView结束后的键盘?
我看到一些类似的问题在这里,但他们没有提供我需要一个解决方案。一些答案建议设置一个的EditText paddingBotton,但是这不是我想要的。我不想空间,我想显示CardView的结束了。
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.
请注意,我不希望调整布局,因此adjustResize不是解决办法,我已经在AndroidManifest.xml中使用adjustPan
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" />
有什么想法?
推荐答案
如果您使用的是滚动型。你可以做的一件事就是你滚动滚动视图根据您的要求。
If you are using scrollview. you can do one thing is to scroll your scrollview as your requirement
请参考下code例如:
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"
这篇关于软键盘打开时显示布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!