【发布时间】:2016-03-04 12:48:27
【问题描述】:
我有一个带有 2 个不同片段的 ViewPager。 对于第一个片段,我想对其进行定义,使其不会在软键盘打开时调整大小。 对于第二个片段,我想让它调整大小。
在清单中设置android:windowSoftInputMode="adjustPan" 将适用于两个片段,但我想在两者之间进行更改。
谷歌搜索后我做了什么:
// 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);
我已将主题自定义为:
<style name="NoResize" parent="@style/AppTheme">
<item name="android:windowSoftInputMode">adjustPan</item>
</style>
活动是使用默认的 windowSoftInputMode 定义的,当软键盘打开时会调整视图的大小。
将一直在解决这个问题,直到它得到解决,但如果其他人有这个问题并解决了它,很高兴听到任何想法。
谢谢!
【问题讨论】:
-
找到解决办法了吗?
标签: android