title: How to add tab inside fragment in android?
body: <p>I try to add tab inside fragment .I can add but the content of particular tab overlap the tab</p>
  
  <p>MainFragmentActivity.java</p>
  
  <pre><code>   public class MainActivity extends FragmentActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);     
      Fragment fragment= new FragmentTab();
          getSupportFragmentManager().beginTransaction().add(R.id.content_frame,fragment).commit();
   }
  
     }
  </code></pre>
  
  <p>activity_main.xml</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" &gt;
  
    &lt;FrameLayout
      android:id="@+id/content_frame"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;  
     &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>FragmentTab.java</p>
  
  <pre><code> public class FragmentTab extends Fragment {
  public FragmentTab() {
  
  }
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
  }
  
  FragmentTabHost mTabHost;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle  
         savedInstanceState) {
      // TODO Auto-generated method stub
      View rootView = inflater.inflate(R.layout.fragment_tabs, container, false);
  
      mTabHost = (FragmentTabHost) rootView.findViewById(android.R.id.tabhost);
      mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.realtabcontent);
      mTabHost.addTab(mTabHost.newTabSpec("fragmentb").setIndicator("Fragment A"),
              FragmentA.class, null);
      mTabHost.addTab(mTabHost.newTabSpec("fragmentc").setIndicator("Fragment B" ),
              FragmentB.class, null);
  
      return rootView;
  }
  
   }
  </code></pre>
  
  <p>fragment_tabs.xml
         </p>
  
  <pre><code> &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;FrameLayout
          android:id="@+id/realtabcontent"
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1" /&gt;
    &lt;/LinearLayout&gt;
  
    &lt;/android.support.v4.app.FragmentTabHost&gt;
  </code></pre>
  
  <p>FragmentA.java</p>
  
  <pre><code>public class FragmentB extends Fragment{
  
  @Override
              public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle 
             savedInstanceState) {
      View rootView= inflater.inflate(R.layout.fragment_a, container,false);
          return rootView;
  }
    }
  </code></pre>
  
  <p>fragment_a.xml
         
       </p>
  
  <pre><code> &lt;TextView
      android:id="@+id/textView2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="FragmentA" /&gt;
  
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>FragmentB.java</p>
  
  <pre><code> public class FragmentB extends Fragment{
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle  
              savedInstanceState) {
          View rootView= inflater.inflate(R.layout.fragment_b, container,false);
          return rootView;
  }
    }
  </code></pre>
  
  <p>fragment_b.xml
       
       </p>
  
  <pre><code>  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="FragmentB" /&gt;
  
     &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Screenshot :</p>
  
  <p><img src="https://i.stack.imgur.com/EELsB.png" alt="enter image description here"></p>
  
  <p>Any help of suggestion would be helpful, I want the content of tab fragment below tab header.
       The content of fragment overlap the tab header.I use FragmentTabHost to use tab layout in fragment<strong>strong text</strong>
  Please help me how to solve this issue.I want the content of tab fragment below tab header.</p>