Question

I'm using PagerSlidingTabStrip for my tabs.

How do I make my tabs fit to screen width?

This is the screenshot, I want to remove the extra space.

EDIT:

Layout file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/shop_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.astuetz.PagerSlidingTabStrip
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="48dip"
        android:background="@drawable/background_tabs"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/shop_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/tabs" />

</RelativeLayout>
Was it helpful?

Solution

Solved it.

PagerSlidingTabStrip itself has its own setting for this, which I've overlooked.

PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);
tabs.setShouldExpand(true);

OTHER TIPS

Is working

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/shop_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:orientation="vertical">

<com.astuetz.PagerSlidingTabStrip
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="48dip"
    android:background="@drawable/background_tabs"
    android:orientation="horizontal"
    android:layout_weight="0"/>

<android.support.v4.view.ViewPager
    android:id="@+id/shop_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/tabs" 
    android:layout_weight="1"/>

 </RelativeLayout>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top