2014-12-09 1 views
1

나는 이미 this solution을 시도했지만 onGlobalLayout()은 결코 호출되지 않습니다. 예, 이미 매니 페스트에 android:windowSoftInputMode="adjustResize"을 설정했습니다. 나는 DrawerLayout 내 활동 루트로 레이아웃을 사용하고 있기 때문에키보드가 탐색 창으로 안드로이드에 표시되는지 확인합니다.

은 어쩌면이다 : 나는 activity_drawer_layout 및 실패 findViewById() 만에 main_fragment_layout을 테스트 한

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/activity_drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<!-- The main content view --> 

<LinearLayout 
    android:id="@+id/main_fragment_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" /> 

<!-- The navigation drawer --> 

<LinearLayout 
    android:id="@+id/user_fragment_layout" 
    android:layout_width="200dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="end" 
    android:orientation="vertical" > 
</LinearLayout> 

</android.support.v4.widget.DrawerLayout> 

을; onGlobalLayout()이 호출되지 않습니다. 도와주세요. 미리 감사드립니다.

답변

2

키보드가 표시되는지 여부를 식별하여 무엇을 달성하려고하는지 잘 모르겠지만 탐색 창을 열었을 때 키보드를 숨기려면 다음을 사용하는 것이 좋습니다.

private void hideKeyboard() { 
    // Check if no view has focus: 
    View view = this.getCurrentFocus(); 
    if (view != null) { 
     InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); 
     inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); 
    } 
} 

코드

은 또한 당신은 키보드가 숨겨 지거나 표시됩니다 알고 How to check visibility of software keyboard in Android?

+0

난 그냥 싶어 살펴 않았다. 그리고 onGlobalLayout() 메서드는 결코 호출되지 않습니다. – Informatheus

관련 문제