您的位置:首页 > 其它

设置透明状态栏后,弹出键盘的冲突问题

2017-03-24 13:44 477 查看
设置透明导航栏

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}


rootView中设置:  

fitsSystemWindows="true"


  键盘弹出模式

android:windowSoftInputMode="adjustResize" 挤压模式

但是此时遇到冲突了,键盘直接遮挡editText了。

参考:http://www.jianshu.com/p/1b22a1d2a7b8

核心代码:重写rootView中的两个方法

@Override
protected boolean fitSystemWindows(Rect insets) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
insets.left = 0;
insets.top = 0;
insets.right = 0;
}
return super.fitSystemWindows(insets);
}

@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, insets.getSystemWindowInsetBottom()));
} else {
return insets;
}
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐