I have this layout but the problem that the tabs doesn't fill the screen like in this photo. I tried the tabgravity method but it doesn't exists in the tabwidget for my layout.
this is my 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>
If anyone can Help me Please?
Use android.support.design.widget.TabLayout
instead of TabHost. Here and here is a good tutorial how to use it properly.
Then, you can use app:tabGravity="fill"
to fill the view.