본문 바로가기
프로그래밍 놀이터/안드로이드, Java

[android] soft input ( keyboard ) visibility 판단

by 돼지왕 왕돼지 2014. 2. 14.
반응형


 android, soft input ( keyboard ) visibility 판단  


[android] soft input ( keyboard ) visibility 판단


private static final int SOFT_INPUT_MINIMUM_HEIGHT = 300;


ViewGroup.getViewTreeObserver().addOnGlobalLayoutListener( new OnGlobalLayoutListener() {

      @Override 

      public void onGlobalLayout() { 

          mIsSoftInputShown = isSoftKeyboardShown( Activity, ViewGroup ); 

      }

});


private boolean isSoftKeyboardShown( Activity activity, View containerView ){

int decorViewHeight = activity.getWindow().getDecorView().getHeight();

int pagerHeight = containerView.getHeight();

return decorViewHeight - pagerHeight > SOFT_INPUT_MINIMUM_HEIGHT;

}




반응형

댓글