1. 程式人生 > >利用佈局實現tablayout標題懸浮在最上面

利用佈局實現tablayout標題懸浮在最上面

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
    android:background="#ffffff"
    android:fitsSystemWindows="true"
    tools:context="social.milin.tech.xuanfu.BannerActivity">


    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">


        <RelativeLayout
            android:id="@+id/rel"
            app:layout_scrollFlags="scroll"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            >
    <com.stx.xhb.xbanner.XBanner
        android:id="@+id/banner"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        app:isAutoPlay="true"
        app:AutoPlayTime="2000"
        app:pointsPosition="CENTER"
        app:isShowNumberIndicator="true"
        app:isHandLoop="true"
        app:placeholderDrawable="@drawable/ic_launcher_background"
        >
    </com.stx.xhb.xbanner.XBanner>
        </RelativeLayout>


    <android.support.design.widget.TabLayout
        android:background="#ffffff"
        android:id="@+id/tablayout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        app:tl_indicator_color="#ff0000"
        app:tl_indicator_height="2dp"
        app:tl_indicator_width="10dp"
        app:tl_underline_color="#ccff00"
        app:tl_underline_height="2dp"
        app:tl_textSelectColor="#ff0000"
        app:tl_textUnselectColor="#000000"
        app:tl_textBold="BOTH"
        >
    </android.support.design.widget.TabLayout>
    </android.support.design.widget.AppBarLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:scrollbars="none"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <android.support.v4.view.ViewPager
        android:id="@+id/vp"
        android:layout_width="match_parent"
        android:layout_height="match_parent">


    </android.support.v4.view.ViewPager>
    </LinearLayout>


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