2014-03-19 140 views
0

我使用PagerSlidingTabStrip爲我的選項卡。刪除額外的空間標籤

如何讓我的選項卡適合屏幕寬度?

這是截圖,我想刪除額外的空間。

編輯:

版式文件

<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> 
+0

應該上傳.xml文件 – Kedarnath

+0

添加了layout xml – AimanB

回答

4

解決它。

PagerSlidingTabStrip本身有它自己的設置,我忽略了它。

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

是工作

<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>