2019-02-27 终极解决Dialog中软键盘弹起引起最下面

2019-02-27  本文已影响0人  萧关逢候骑11

1、最外层布局自定义,重写onSizeChanged方法

public class CusSoftKeybordLinearlayoutextends LinearLayout {

private final StringTAG = CusSoftKeybordLinearlayout.class.getSimpleName();

private SoftKeybordListenerl;

public CusSoftKeybordLinearlayout(Context context) {

super(context);

}

public CusSoftKeybordLinearlayout(Context context, AttributeSet attrs) {

super(context, attrs);

}

public CusSoftKeybordLinearlayout(Context context, AttributeSet attrs,int defStyleAttr) {

super(context, attrs, defStyleAttr);

}

@Override

    protected void onSizeChanged(int w,int h,int oldw,int oldh) {

super.onSizeChanged(w, h, oldw, oldh);

if (oldh > h) {

CusLogcat.showDLog(TAG,"input window show");

l.softKeybordShow();

}else {

CusLogcat.showDLog(TAG,"input window hidden");

l.softKeybordHide();

}

}

public void setSoftKeybordListener(SoftKeybordListener listener) {

l = listener;

}

}

上一篇 下一篇

猜你喜欢

热点阅读