title: How to confine a ViewPager into a fragment rather than occupy the entire screen?
body: <p>The layout of the app I am working on is the classical two-pane master-detail layout. In the leftpane the menu, in the rightpane the fragments that are shown as a result of pressing a menu item. One of the menu items initiates a ViewPager swiping structure. This ViewPager structure consists of a ScreenSlideActivity and a ScreenSlidePageFragment classes. The first class, as is standard, holds a pointer to the ViewPager object, the adapter (ScreenSlidePagerAdapter) with the essential methods like getItem and getFragment.</p>
  
  <p>Everything works fine, except that the ViewPager occupies the entire screen, rather than in the right panel.</p>
  
  <p><strong>Question: how can I get the ViewPager to confine itself to the right panel, rather than occupying the entire screen?</strong></p>
  
  <p>Here is the layout of the two_pane, generated automatically by Eclipse when generating a master-detail template project:</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:layout_marginLeft="16dp"
      android:layout_marginRight="16dp"
      android:baselineAligned="false"
      android:divider="?android:attr/dividerHorizontal"
      android:orientation="horizontal"
      android:showDividers="middle"
      tools:context=".ItemListActivity" &gt;
  
      &lt;!--
      This layout is a two-pane layout for the Items
      master/detail flow. See res/values-large/refs.xml and
      res/values-sw600dp/refs.xml for an example of layout aliases
      that replace the single-pane version of the layout with
      this two-pane version.
  
      For more on layout aliases, see:
      http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
      --&gt;
  
  &lt;LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;fragment
          android:id="@+id/item_list"
          android:name="com.company.ItemListFragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_weight="1"
          tools:layout="@android:layout/list_content" /&gt;
  
          &lt;ImageView
          android:id="@+id/imageView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginLeft="10dip"
          android:layout_marginRight="20dip"
          android:layout_marginTop="10dip"
          android:layout_marginBottom="20dip"
          android:src="@drawable/icon" /&gt;
  
      &lt;/LinearLayout&gt;
      &lt;FrameLayout
          android:id="@+id/item_detail_container"
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:layout_weight="3" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The menu item that kicks off the ViewPager does this:</p>
  
  <pre><code>Intent intent = new Intent(this, ScreenSlideNewActivity.class);
  startActivity(intent);
  </code></pre>
  
  <p>I found a hint to a solution from <a href="https://groups.google.com/forum/#!topic/android-developers/thoSZJXPzdw" rel="nofollow">an old post here</a>, but that's based on the deprecated ActivityGroup (solution at the bottom).</p>