使用“adjustPan"或“调整调整大小"特定于片段 [英] Using "adjustPan" or "adjustResize" specific to a fragment

查看:25
本文介绍了使用“adjustPan"或“调整调整大小"特定于片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以以编程方式或在xml中指定一种使用特定于windowSoftInputMode的方法片段.

假设我只有一个 activity 包含两个 fragment,一个片段应该使用 adjustPan,另一个片段应该使用 adjustResize.我应该如何管理?

谢谢!

解决方案

您可以通过编程方式更改行为,请参阅此答案.

那么我会怎么做:如果片段 A 恢复,使用 getActivity() 获取对其父活动的引用,然后使用问题中的命令来更改行为.>

然后对片段 B 执行相同的操作,但在设置软输入模式行为时使用另一个参数.

  • adjustResize 将是:WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
  • adjustPan 将是:WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN

I'm wondering if it's possible to specify programatically or in the xml a way to use a windowSoftInputMode specific to a Fragment.

Let's say I have just one activity that contains two fragment, one fragment should use adjustPan and the other one adjustResize. How should I manage this?

Thanks!

解决方案

You can change the behavior programmatically, see this answer for that.

So what I would do: if fragment A is resumed, use getActivity() to get a reference to its parent activity, and then use the command from the question to change the behavior.

Then do the same with fragment B, but use the other parameter when setting the soft input mode behavior.

  • adjustResize would be: WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
  • adjustPan would be: WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN

这篇关于使用“adjustPan"或“调整调整大小"特定于片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆