title: Android get WebView height
body: <p>I have a WebView defined in my XML:</p>
  
  <pre><code>&lt;WebView
      android:id="@+id/streetview_webview"
      android:layout_width="match_parent"
      android:layout_height="164dp"
      android:layout_alignParentLeft="true"
      android:layout_below="@+id/header" /&gt;
  </code></pre>
  
  <p>Now I want to get the height of this WebView inside my code, to exclude the webview scrolling from scrolling my CustomViewPager</p>
  
  <pre><code>@Override
  public boolean onInterceptTouchEvent(MotionEvent event) {
      if (childId &gt; 0) {
          View webv = findViewById(R.id.webView1);
          if (webv != null) {
              int x = webv.getLeft();
              int x2 = x + webv.getLayoutParams().width;
  
              int y = webv.getTop();
              int y2 = y + webv.getMeasuredHeight();
  
              int targetx = (int) event.getX();
              int targety = (int) event.getY();
  
              if (targetx &gt; x &amp;&amp; targetx &lt; x2 &amp;&amp; targety &gt; y &amp;&amp; targety &lt; y2) {
                  return false;
              }
          }
      }
      return super.onInterceptTouchEvent(event);
  }
  </code></pre>
  
  <p>I have tried</p>
  
  <p><code>webv.getHitRect</code> but this gets the height of the parent (the whole screen)</p>
  
  <pre><code>webv.getLayoutParams().width; // &lt;- working
  webv.getLayoutParams().height; // -1
  </code></pre>
  
  <p>and </p>
  
  <pre><code>webv.getHeight
  </code></pre>
  
  <p>But none of them getting me the 164dp height.</p>
  
  <p><strong>edit:</strong> Thanks guys Akos Cz is right.</p>