[英]Android layout getting wrapped when keyboard appears
In my application I have two tabs, for which I am using ViewPager
, two fragments are within this view pager. 在我的应用程序中,我有两个选项卡,我正在使用ViewPager
,这个视图分页器中有两个片段。 Sometimes when I tap on first tabs fragments EditBox
keyboard pops, once I am done with the input keyboard disappears. 有时当我点击第一个标签片段时, EditBox
键盘弹出,一旦我完成输入键盘就消失了。 But layout below keyboard region goes blank (White), this is happening sometimes, specially second launch of application. 但是键盘区域下方的布局变为空白(白色),这有时会发生,特别是第二次启动应用程序。 When application is launched from studio for first time issue doesn't appear. 第一次从工作室启动应用程序时不出现问题。 But when I launch it through system application by tapping on its ic_launhcher
issue comes again. 但是,当我通过系统应用程序通过点击其ic_launhcher
问题再次启动它时。 What are the possible causes of issue ? 问题的可能原因是什么?
The layout on launch looks like : 启动时的布局如下:
After I click on edit box & edit some text in address filed, when keyboard disappears, layout looks like : 单击编辑框并编辑地址字段中的某些文本后,当键盘消失时,布局如下所示:
I am using view pager inside another fragment & using FragmentStatePagerAdapter
by passing a getChildFragmentManager()
我在另一个片段中使用view pager并通过传递getChildFragmentManager()
使用FragmentStatePagerAdapter
private void setupViewPager(ViewPager viewPager) {
FragmentStatePagerAdapter fragmentStatePagerAdapter = new FragmentStatePagerAdapter(getChildFragmentManager()) {
@Override
public Fragment getItem(int position) {
Fragment fragment = null;
switch (position) {
case 0:
fragment = new GeneralInfoFragment();
Bundle bundle = new Bundle();
bundle.putString(context.getString(R.string.all_data), new Gson().toJson(profileResponse));
fragment.setArguments(bundle);
break;
case 1:
fragment = new ICEFragment();
break;
default:
return null;
}
return fragment;
}
@Override
public int getCount() {
return 2;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "General Info";
case 1:
return "ICE";
}
return "";
}
};
Note : Images are erased to protect privacy 注意:图像被删除以保护隐私
Edit: 编辑:
Put this code in your manifest file in your activity tag 将此代码放入活动代码中的清单文件中
android:configChanges="keyboard|keyboardHidden|orientation|
screenLayout|uiMode|screenSize|smallestScreenSize"
android:windowSoftInputMode="stateHidden|adjustPan"
Or 要么
Try this one 试试这个吧
setContentView(R.layout.activity_direction_3);
getWindow().getDecorView().setBackgroundColor(
android.R.color.transparent);
Or 要么
if you have are using a custom theme then add this in your theme 如果您使用的是自定义主题,请在主题中添加此主题
<item name="android:windowBackground">Transparent color </item>
Tel me if you still get the issue. 如果你仍然遇到问题,请打电话给我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.