title: How to set gravity to a ViewPager in a LinearLayout
body: <p>I'd like to know if there's exists a way to set gravity to a ViewPager inside a LinearLayout, I tried something like this but it gives me an error.</p>
  
  <pre><code>    &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context="com.fragProjects.MainActivity"&gt;
  
      &lt;fragment
          android:id="@+id/displayFragment"
          android:name="com.fragProjects.DisplayFragment"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          tools:layout="@layout/fragment_display" /&gt;
  
  
          &lt;android.support.v4.view.ViewPager
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="1"
              android:id="@+id/viewPager"&gt;
          &lt;/android.support.v4.view.ViewPager&gt;
  
      &lt;fragment
          android:id="@+id/basicFragment"
          android:name="com.fragProjects.BasicFragment"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1.2"
          tools:layout="@layout/fragment_basic" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I need the ViewPager in the middle of both Fragments, and I need them with the same size each one, that's why I tried to use gravity.</p>
  
  <p>If you need the MainActivity where the ViewPager is declared is the following one:</p>
  
  <pre><code>    import android.net.Uri;
      import android.support.v4.app.Fragment;
      import android.support.v4.app.FragmentActivity;
      import android.support.v4.app.FragmentManager;
      import android.support.v4.app.FragmentStatePagerAdapter;
      import android.support.v4.view.PagerAdapter;
      import android.support.v4.view.ViewPager;
      import android.support.v7.app.AppCompatActivity;
      import android.os.Bundle;
  
  public class MainActivity extends FragmentActivity implements AdvancedFragment.OnFragmentInteractionListener {
  
      //Number of pages that advanced function ViewPager has.
      private static final int NUM_PAGES = 2;
      //ViewPager that will allow us to swip to access 'shift' advances options.
      protected ViewPager mViewPager;
      //The adapter of previous ViewPager is this.
      protected PagerAdapter mPagerAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          //Instantiate ViewPager and PagerAdapter
          mViewPager = (ViewPager) findViewById(R.id.viewPager);
          mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
          mViewPager.setAdapter(mPagerAdapter);
          mViewPager.setCurrentItem(0);
          mViewPager.getCurrentItem();
  
      }
  
      @Override
      public void onFragmentInteraction(Uri uri) {
  
      }
  
  
      /**
            * A simple pager adapter that represents 2 ScreenSlidePageFragment objects, in
            * sequence.
            */
      private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
          public ScreenSlidePagerAdapter(FragmentManager fm) {
              super(fm);
          }
  
          @Override
          public Fragment getItem(int position) {
              switch (position){
                  case 0:
                      return AdvancedFragment.newInstance("", "Page # 1");
                  case 1:
                      //return
                      return AdvancedFragment.newInstance("","");
                  default:
                      return null;
              }
          }
  
          @Override
          public int getCount() {
              return NUM_PAGES;
          }
      }
  }
  </code></pre>
  
  <p>If I erase the layout_gravity parameter from the ViewPager and run the application, the ViewPager takes all the screen like we had set its height with 'match_parent', but we didn't set that...</p>
  
  <p>Is it normal in ViewPagers? Does exists a solution for this? 
  Greetings!</p>