我有一个包含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);
Run Code Online (Sandbox Code Playgroud)
我自定义了主题:
<style name="NoResize" parent="@style/AppTheme">
<item name="android:windowSoftInputMode">adjustPan</item>
</style>
Run Code Online (Sandbox Code Playgroud)
使用默认的windowSoftInputMode定义活动,该软件会在软键盘打开时调整视图大小.
将会解决这个问题,直到它得到解决,但如果其他人有这个问题并解决了它,那么听到任何想法都会很棒.
谢谢!
Mox*_*xor 75
您可以调用每个onCreateView
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Run Code Online (Sandbox Code Playgroud)
在我的情况下,这并没有解决问题,因为我有一个透明的片段(一个聊天窗口),我需要调整大小,底部的片段不应该.但我认为这对你有用.
| 归档时间: |
|
| 查看次数: |
23376 次 |
| 最近记录: |