简体   繁体   English

防止Android软键盘在片段中向上移动视图?

[英]Preventing the Android soft keyboard from moving the view up in a Fragment?

I have an activity with four tabs and every tab is implemented as a fragment. 我有一个包含四个选项卡的活动,每个选项卡都实现为一个片段。 In one of these tabs I would like to prevent the soft keyboard from pushing up the view, while the keyboard should still push the views up in the other fragments. 在其中一个选项卡中,我想阻止软键盘向上推视图,而键盘仍然应该将视图推到其他片段中。 Does anybody know how to achieve this? 有谁知道如何实现这一目标?

I cannot use the activity's windowSoftInputMode flag, because that would prevent it for the whole activity with all four fragments. 我无法使用activity的windowSoftInputMode标志,因为这会阻止整个活动的所有四个片段。

Try to change flag dynamically 尝试动态更改标志

Use the following to change the softInputMode for an Activity in your tab click listener. 使用以下命令更改选项卡单击侦听器中的Activity的softInputMode。

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM