2016-01-08 79 views
1

我正在使用設計支持庫來創建選項卡。在我的代碼,我有我的選項卡中設置固定下來,並填補像父:Android選項卡不要填寫父項

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="io.github.ncca_fbla.fabric.MainActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:theme="@style/Toolbar"/> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      app:tabMode="fixed" 
      app:tabGravity="fill"/> 
    </android.support.design.widget.AppBarLayout> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/viewpager" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

     <android.support.design.widget.FloatingActionButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom|end" 
      android:layout_margin="@dimen/fab_margin" 
      android:src="@drawable/ic_add" 
      app:fabSize="normal"/> 

</android.support.design.widget.CoordinatorLayout> 

這應該工作正常,但我的標籤不灌裝工具欄:

Tabs not filling

有什麼事情我做錯了?

回答

3

TabLayout"wrap_content"的變化android:layout_width"match_parent"

<android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:tabMode="fixed" 
      app:tabGravity="fill"/> 
+0

-_-我不能相信我沒有想到這一點。謝謝。 –