suppender of AndroidStudy
12/16/2016 - 2:03 PM

app:tabMode:可以取如下两个值, fixed:表示Tab不能滚动 scrollable:表示Tab可以滚动,此时不管tabGravity取何值,都是按照从左到右排过去,即相当于app:tabGravity="left"(当然了,实际中没有 le

app:tabMode:可以取如下两个值, fixed:表示Tab不能滚动 scrollable:表示Tab可以滚动,此时不管tabGravity取何值,都是按照从左到右排过去,即相当于app:tabGravity="left"(当然了,实际中没有 left这个值,只是我们可以这么去理解) app:tabGravity:可以取如下两个值, fill:当tabMode取fixed时(即tab不能滚动时),tab的所有子标签填充tab的宽度 center:当tabMode去fixed时,tab中所有子标签居中显示。

<!--app:tabMode:可以取如下两个值,
fixed:表示Tab不能滚动 
scrollable:表示Tab可以滚动,此时不管tabGravity取何值,都是按照从左到右排过去,即相当于app:tabGravity="left"(当然了,实际中没有 left这个值,只是我们可以这么去理解) 
app:tabGravity:可以取如下两个值, 
fill:当tabMode取fixed时(即tab不能滚动时),tab的所有子标签填充tab的宽度 center:当tabMode去fixed时,tab中所有子标签居中显示。-->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.hc.materialdesign.MainActivity">


    <android.support.design.widget.TabLayout
        android:id="@+id/tablayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark"
        app:tabGravity="center"
        app:tabMode="fixed" />

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

</LinearLayout>