沉浸式布局与输入法不兼容问题

来源:互联网 发布:战争潜力知乎 编辑:程序博客网 时间:2024/06/05 09:27

问题:当采用沉浸式布局时,底部的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"


这两部就能解决沉浸式与输入法的问题



0 0