0

Ich habe dieses Layout, aber das Problem, dass die Tabs nicht den Bildschirm füllen, wie in diesem Foto. Ich habe versucht, die Tabgravity-Methode, aber es ist nicht in der Tabwidget für mein Layout vorhanden.Tabs füllen nicht die gesamte Ansicht

enter image description here

das ist mein layout.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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" 
    tools:context="com.subhi.navtabs.MainActivity"> 


    <TabHost 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@android:id/tabhost" 
     > 



     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <HorizontalScrollView 
       android:layout_width="match_parent" 
       android:id="@+id/h_Scroll_View" 
       android:layout_height="wrap_content"> 


       <TabWidget 
        android:id="@android:id/tabs" 
        android:fillViewport="true" 
        android:scrollbars="none" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"></TabWidget> 

      </HorizontalScrollView> 



      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <android.support.v4.view.ViewPager 
        android:layout_width="match_parent" 
        android:id="@+id/viewpager" 
        android:layout_height="match_parent"></android.support.v4.view.ViewPager> 
      </FrameLayout> 
     </LinearLayout> 
    </TabHost> 
</RelativeLayout> 

Wenn jemand mir bitte helfen?

Antwort

0

Verwenden Sie android.support.design.widget.TabLayout anstelle von TabHost. Here und here ist ein gutes Tutorial, wie man es richtig benutzt. Dann können Sie app:tabGravity="fill" verwenden, um die Ansicht zu füllen.