title: How to get Width and Height of ViewPager in android?
body: <p>I have a single ViewPager in my activity. The xml code of my activity is - </p>
  
  <pre><code>&lt;android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" 
           android:id="@+id/pager"     
           android:layout_width="match_parent"
           android:layout_height="match_parent" /&gt;
  </code></pre>
  
  <p>I want to know it's Height and Width (which in this case should be the entire area covered by my application). <strong>Problem is I want to know these sizes before I send data to viewpager</strong>.</p>
  
  <p>I tried to use as following -</p>
  
  <pre><code>pager= (ViewPager) findViewById(R.id.pager);
  int width = pager.getWidth();
  int height = pager.getHeight();
  </code></pre>
  
  <p>but both of them always returns 0.</p>
  
  <p><strong>Why is returning to Zero, when I have set properties to "match_parent"?</strong></p>
  
  <p><strong>and How to get the dimensions?</strong></p>
  
  <p>Edit 1 - At present activity xml has viewpager alone, should I place it in linear/relative layout to find dimensions?</p>
  
  <p>Thanks. Regards,</p>