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;
}
}
网友评论