美文网首页Android开发
BottomNavigationView嵌套fragment有输

BottomNavigationView嵌套fragment有输

作者: 大BO啫 | 来源:发表于2020-03-29 10:17 被阅读0次

最近开发的时候发现了这个问题,然而网上说的办法,都是在根布局加上什么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~~~

相关文章

网友评论

    本文标题:BottomNavigationView嵌套fragment有输

    本文链接:https://www.haomeiwen.com/subject/dysyuhtx.html