title: android soft keyboard steal the height
body: <p>I have write a util to expand view, code like this</p>
  
  <pre><code>public static void expand(final View v) {
      int initialHeight = v.getHeight();
      int targetHeight = ((View)v.getParent()).getHeight();
      expand(v, initialHeight, targetHeight);
  }
  </code></pre>
  
  <p>It works most of the time, but ... </p>
  
  <p><strong>Problem</strong></p>
  
  <p>when I want to expand view in <code>edittext.onClickListener()</code>, it sucks. Because when click the edittext , the keyboard will pop up, and the <code>v.getParent().getHeight()</code> include the keyboard height.</p>
  
  <p><strong>WANT</strong></p>
  
  <p>to make <code>expand(view)</code> fit the <code>edittext.onClickListener()</code>, fill the blank layout(exclude keyboard) with the view.</p>
  
  <p><strong>Try</strong></p>
  
  <p>try to use <code>expand(v, v.getHeight(), ((View)v.getParent()).getHeight() - keyboardHeight);</code>, but fail to get keyboard height</p>
  
  <p>try to use measuredHeight</p>
  
  <pre><code>view.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
  </code></pre>
  
  <p>but why view.getMeasuredHeight() return 36 pixel, it is a wrong height</p>
  
  <p>Any suggestion is welcome.</p>