title: How to set margin with ViewPager filling the parent
body: <p>I have some problems with my application. I have the next activity:</p>
  
  <p><img src="https://i.stack.imgur.com/40fRp.png" alt="enter image description here"></p>
  
  <p>This activity has a ViewPager (the rounded rectangle with the gradient colour) and I need to set margins or padding to right and left. I thought in this solution:</p>
  
  <pre><code>&lt;ViewPager
  android:layout_marginRight="20dp"
  android:layout_marginLeft="20dp"/&gt;
  </code></pre>
  
  <p>Doing this, but adding margin only to right, it looks like:</p>
  
  <p><img src="https://i.stack.imgur.com/wTCZi.png" alt="enter image description here"></p>
  
  <p>But this is a problem because I get the next results when swipping the screen:</p>
  
  <p><img src="https://i.stack.imgur.com/BzqMZ.png" alt="enter image description here"></p>
  
  <p>As you can see, the fragment doesn't appears from the screen limit, but it appears from the margin I set to ViewPager.</p>
  
  <p>What I need is to have the ViewPager filling the parent horizontally but with the rounded rectangle limited by right and left due to some kind of margin.</p>
  
  <p>I have already tried to set the margin directly to the fragment's XML code but it doesn't reflects any effect.</p>
  
  <p>Hope you can help me.</p>