您的位置:首页 > 其它

[置顶] 沉浸式布局与输入法不兼容问题

2016-07-28 09:02 381 查看
问题:当采用沉浸式布局时,底部的edittext 弹出输入法遮挡住 edittext。

解决方法

1.采用systembartint 替代原有的沉浸式

1.oncrate()方法中加入

if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT) {
setTranslucentStatus(true);
}
//创建状态栏管理实例
SystemBarTintManager  manager=new SystemBarTintManager(this);
//激活状态栏设置
manager.setStatusBarTintEnabled(true);
manager.setStatusBarTintResource(R.color.title_background);

@TargetApi(19)
private  void setTranslucentStatus(boolean on){
Window win = getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
if (on) {
winParams.flags |= bits;
} else {
winParams.flags &= ~bits;
}
win.setAttributes(winParams);
}

2. 所在activity的根布局中加入    android:fitsSystemWindows="true"

这两部就能解决沉浸式与输入法的问题
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: