title: Why my layout shrinks while in viewpager but looks fine in the separate layout xml?
body: <p>I am using a fragment in a viewpager and when i run it on emulator/device it shrinks and certain text views disappear. But when i view the resource layout of the fragment separately then it just looks fine</p>
  
  <p><strong>This is how it looks while running on emulator/device : Activity</strong>
  <a href="https://i.stack.imgur.com/lFc2V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lFc2V.png" alt="enter image description here"></a></p>
  
  <p>Layout of activity</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto"
          android:id="@+id/activity_landing_page"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:paddingBottom="@dimen/activity_vertical_margin"
          android:paddingLeft="16dp"
          android:paddingRight="16dp"
          tools:context="com.thebitshoes.uocn.AdminHome"
          android:orientation="vertical"
          android:weightSum="3"&gt;
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:orientation="horizontal"&gt;
          &lt;ImageView
              android:layout_width="326dp"
              android:layout_height="wrap_content"
              android:src="@mipmap/admin_bg_pic"
              android:layout_gravity="center_horizontal" /&gt;
          &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:src="@mipmap/profile_icon"
              android:layout_alignParentBottom="true"
              android:layout_centerHorizontal="true"
              android:layout_marginBottom="23dp" /&gt;
      &lt;/RelativeLayout&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          android:weightSum="1"
          android:background="#737D8C"&gt;
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="?attr/actionBarSize"
              android:background="#bfd919"
              android:orientation="horizontal"&gt;
              &lt;LinearLayout
                      android:layout_width="0dp"
                      android:layout_height="match_parent"
                      android:layout_weight="40"
                      android:background="#3c424c"
                      android:orientation="horizontal"&gt;
                  &lt;ImageView
                          android:id="@+id/message_icon"
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center_vertical"
                          android:layout_weight="1"
                          android:src="@mipmap/message_icon_new" /&gt;
                  &lt;ImageView
                          android:id="@+id/notification_icon"
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center_vertical"
                          android:layout_weight="1"
                          android:src="@mipmap/notification_icon" /&gt;
              &lt;/LinearLayout&gt;
              &lt;LinearLayout
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:layout_weight="57.93"
          android:background="#737d8c"
          android:orientation="horizontal"&gt;
                  &lt;LinearLayout
              android:paddingLeft="10dp"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="center_vertical"
                                      &gt;
                      &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="center_vertical"
                  android:padding="5dp"
                  android:text="Welcome Back, John Doe !"
                  android:fontFamily="sans-serif-light"
                  android:textColor="#ffffff"
                  android:textSize="14sp" /&gt;
                  &lt;/LinearLayout&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="2.1"
          android:orientation="vertical"
          &gt;
          &lt;android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true" /&gt;
          &lt;android.support.design.widget.TabLayout
          android:id="@+id/tab_layout"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          app:tabBackground="@drawable/tab_color_selector"
          app:tabTextColor="#3C424D"
          android:layout_alignParentTop="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true" /&gt;
          &lt;android.support.v4.view.ViewPager
              android:id="@+id/pager"
              android:layout_width="match_parent"
              android:layout_height="fill_parent"
              android:layout_below="@+id/toolbar" /&gt;
      &lt;/RelativeLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Below is the layout of the fragment as viewed separately, Fragment XML</strong></p>
  
  <p><a href="https://i.stack.imgur.com/EAWpS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EAWpS.png" alt="enter image description here"></a></p>
  
  <p>Layout of Fragment used in viewpager</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:weightSum="1"&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="0.18"
          android:background="@drawable/cards"
          android:orientation="horizontal"&gt;
          &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:src="@mipmap/student_icon" /&gt;
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"
              android:layout_marginLeft="16dp"
              android:layout_marginStart="16dp"&gt;
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="STUDENTS"
                  android:textStyle="bold"
                  android:textSize="18sp" /&gt;
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="15dp"
                  android:orientation="vertical"&gt;
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="30 admissions in the past 10 days" /&gt;
                  &lt;LinearLayout
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:orientation="horizontal"&gt;
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:textStyle="bold"
                          android:text="Total"
                          android:layout_marginTop="6dp" /&gt;
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="100"
                          android:layout_marginTop="6dp"
                          android:layout_marginLeft="8dp" /&gt;
                  &lt;/LinearLayout&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
      &lt;View
          android:layout_width="match_parent"
          android:layout_height="1dp"
          android:background="@android:color/darker_gray"/&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="0.18"
          android:background="@drawable/cards"
          android:orientation="horizontal"
          &gt;
          &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:src="@mipmap/books_icon" /&gt;
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"
              android:layout_marginLeft="16dp"
              android:layout_marginStart="16dp"&gt;
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="COURSES"
                  android:textStyle="bold"
                  android:textSize="18sp" /&gt;
              &lt;LinearLayout
                  android:layout_width="252dp"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="15dp"
                  android:orientation="vertical"&gt;
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="12 course updates 2 months" /&gt;
                  &lt;LinearLayout
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:orientation="horizontal"&gt;
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:textStyle="bold"
                          android:text="Total"
                          android:layout_marginTop="6dp" /&gt;
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="100"
                          android:layout_marginTop="6dp"
                          android:layout_marginLeft="8dp" /&gt;
                  &lt;/LinearLayout&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
      &lt;View
          android:layout_width="match_parent"
          android:layout_height="1dp"
          android:background="@android:color/darker_gray"/&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="0.18"
          android:background="@drawable/cards"
          android:orientation="horizontal"
          &gt;
          &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:src="@mipmap/parent_icon" /&gt;
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"
              android:layout_marginLeft="16dp"
              android:layout_marginStart="16dp"&gt;
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="PARENTS"
                  android:textStyle="bold"
  
                  android:textSize="18sp" /&gt;
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="15dp"
                  android:orientation="vertical"&gt;
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="10 records added yesterday" /&gt;
                  &lt;LinearLayout
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:orientation="horizontal"&gt;
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:textStyle="bold"
                          android:text="Total"
                          android:layout_marginTop="6dp" /&gt;
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="200"
                          android:layout_marginTop="6dp"
                          android:layout_marginLeft="8dp" /&gt;
                  &lt;/LinearLayout&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
      &lt;View
          android:layout_width="match_parent"
          android:layout_height="1dp"
          android:background="@android:color/darker_gray"/&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="0.18"
          android:background="@drawable/cards"
          android:orientation="horizontal"
          &gt;
          &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:src="@mipmap/teacher_icon" /&gt;
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"
              android:layout_marginLeft="16dp"
              android:layout_marginStart="16dp"&gt;
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="TEACHERS"
                  android:textStyle="bold"
                  android:textSize="18sp" /&gt;
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="15dp"
                  android:orientation="vertical"&gt;
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="10 active teachers"
                      android:textStyle="bold"
                      /&gt;
                  &lt;LinearLayout
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:orientation="horizontal"&gt;
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:textStyle="bold"
                          android:text="Total"
                          android:layout_marginTop="6dp" /&gt;
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="10"
                          android:layout_marginTop="6dp"
                          android:layout_marginLeft="8dp" /&gt;
                  &lt;/LinearLayout&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
      &lt;View
          android:layout_width="match_parent"
          android:layout_height="1dp"
          android:background="@android:color/darker_gray"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>