变windowSoftInputMode为viewpager内片段 [英] Varying windowSoftInputMode for fragments inside the viewpager

查看:105
本文介绍了变windowSoftInputMode为viewpager内片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个不同的片段一个ViewPager。 对于第一个片段,我想定义它,使它不会在软键盘开调整。 对于第二个片段,我想拥有它调整。

设置机器人:windowSoftInputMode =adjustPan里面的表现会为两个片段,但我想改变这两者之间

我的谷歌搜索后所做的:

  //从原来的活动上下文的自定义主题创建ContextThemeWrapper
    上下文的背景下=新ContextThemeWrapper(getActivity(),R.style.NoResize);
    //克隆使用ContextThemeWrapper充气
    LayoutInflater localInflater = inflater.cloneInContext(上下文);
    //使用充气克隆充气,而不是通过默认
    返回localInflater.inflate.inflate(R.layout.my_layout,集装箱,假);
 

我自定义的主题是:

 <样式名称=NoResize父=@风格/ AppTheme>
    <项目名称=机器人:windowSoftInputMode> adjustPan< /项目>
< /风格>
 

该活动定义默认windowSoftInputMode其重新调整的意见时softkeyboard打开了。

将致力于此,直到它得到解决,但如果任何人有这个问题,并解决它,这将是真棒听到任何想法。

谢谢!

解决方案

您可以在每个onCreateView叫

<$p$p><$c$c>getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

检查<一href="http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#SOFT_INPUT_ADJUST_RESIZE">http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#SOFT_INPUT_ADJUST_RESIZE

在我而言,这并不能解决问题,因为我有一个tranparent片段(聊天)至极我需要调整,并在底部应该不是frangment。但我认为这可能是有用的给你。

I have a ViewPager with 2 different fragments. For the first fragment, I would like to define it so that it does not resize upon the soft keyboard opening. For the second fragment, I would like to have it resize.

Setting the android:windowSoftInputMode="adjustPan" inside the manifest will work for both fragments, but I want to vary it between the two.

What I've done after google searches :

    // create ContextThemeWrapper from the original Activity Context with the custom theme
    Context context = new ContextThemeWrapper(getActivity(), R.style.NoResize);
    // clone the inflater using the ContextThemeWrapper
    LayoutInflater localInflater = inflater.cloneInContext(context);
    // inflate using the cloned inflater, not the passed in default
    return localInflater.inflate.inflate(R.layout.my_layout,container,false);

I've custom defined the theme to be :

<style name="NoResize" parent="@style/AppTheme">
    <item name="android:windowSoftInputMode">adjustPan</item>
</style>

The activity is defined with default windowSoftInputMode which resizes the views when softkeyboard opens up.

Will be working on this until it gets solved but if anyone else has this problem and solved it, it would be awesome to hear any thoughts.

Thanks!

解决方案

You can call on each onCreateView

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

check http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#SOFT_INPUT_ADJUST_RESIZE

In my case, this doesn't solve the problem, because I have a tranparent Fragment (a chat) wich I need to resize and the frangment on the bottom shouldn't. but I think it could be usefull to you.

这篇关于变windowSoftInputMode为viewpager内片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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