最近开发的时候发现了这个问题,然而网上说的办法,都是在根布局加上什么hidden之类的,没用!!!
于是想到了另一个办法,当检测到有输入法键盘弹起时,让bottomview消失,invisible,然后检测到输入法收起时,再展开即可,简直完美~~代码如下:
bottomView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (bottom - oldBottom < -1) {
//软键盘弹上去了
bottomView.setVisibility(View.INVISIBLE);
}else if (bottom - oldBottom >1) {
//软键盘弹下去了
bottomView.setVisibility(View.VISIBLE);
}
}
});
此外说明一下,这个bottomView是我包在BottomNavigationView外的一层RelativeLayout~~~