我的GridView android:layout_height="match_parent"
带有编辑框,在LinearLayout
中修复android:layout_height 。
当我触摸编辑框时,会出现键盘。
当键盘出现并消失时,如何在LinearLayout中更改android:layout_height?
答案 0 :(得分:0)
请尝试以下链接,希望它可以帮助您
http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html
http://davidwparker.com/2011/08/30/android-how-to-float-a-row-above-keyboard/
private OnSoftKeyboardListener onSoftKeyboardListener;
@Override
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
if (onSoftKeyboardListener != null) {
final int newSpec = MeasureSpec.getSize(heightMeasureSpec);
final int oldSpec = getMeasuredHeight();
if (oldSpec > newSpec){
onSoftKeyboardListener.onShown();
} else {
onSoftKeyboardListener.onHidden();
}
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
public final void setOnSoftKeyboardListener(final OnSoftKeyboardListener listener) {
this.onSoftKeyboardListener = listener;
}
public interface OnSoftKeyboardListener {
public void onShown();
public void onHidden();
}