2013-01-21 133 views
1

我有GridView android:layout_height="match_parent"與Editboxes,在LinearLayout修復android:layout_height如何獲得顯示鍵盤事件android

當我觸摸編輯框時,出現鍵盤。

如何在出現鍵盤和消失時在LinearLayout中更改android:layout_height?

+0

希望它爲你工作.. – Janmejoy

+0

謝謝!我現在嘗試。我是Android新手,需要一些時間。 – Ivan

回答

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(); 
} 
+0

更詳細的答案在這裏http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android/4737265#4737265 – Ivan