首页 > 其他 > 详细

CoordinatorLayout+TabLayout+ViewPager

时间:2017-01-03 20:54:42      阅读:526      评论:0      收藏:0      [点我收藏+]
<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#eee">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="480dp">


        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed|snap">
            <!--内容-->

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#F5F6F9"
                android:orientation="vertical">

                <Space
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:background="#ccc" />

                <ImageView
                    android:id="@+id/imageView_banner"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:scaleType="fitXY" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:background="#fff"
                    android:gravity="center_vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingLeft="10dp"
                        android:text="精选推荐" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingLeft="10dp"
                        android:text="不容错过的品牌呦"
                        android:textColor="#FC5A83"
                        android:textSize="10sp" />

                </LinearLayout>

                <GridView
                    android:id="@+id/gridView_brand"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:background="#FBFDFA"
                    android:numColumns="3" />

                <Space
                    android:layout_width="match_parent"
                    android:layout_height="10dp"
                    android:background="#ccc" />

                <GridView
                    android:id="@+id/gridView_shops"
                    android:layout_width="match_parent"
                    android:layout_height="90dp"
                    android:background="#FBFDFA"
                    android:numColumns="3" />

                <Space
                    android:layout_width="match_parent"
                    android:layout_height="10dp"
                    android:background="#ccc" />
            </LinearLayout>


            <!--利用toolbar 为模拟的toolbar和tablayout 进行占位,设置不收缩-->
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="80dp"
                android:gravity="top"
                android:minHeight="?attr/actionBarSize"
                app:contentInsetEnd="0dp"
                app:contentInsetLeft="0dp"
                app:contentInsetRight="0dp"
                app:contentInsetStart="0dp"
                app:layout_collapseMode="pin">
                <!--模拟toolbar部分-->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:background="#fff"
                    android:orientation="horizontal">

                    <ImageView
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:src="@drawable/header_btn_noti_new" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="私密搭"
                        android:textSize="20sp" />

                    <ImageView
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:src="@drawable/header_btn_nocart" />
                </LinearLayout>
            </android.support.v7.widget.Toolbar>
            <!--tablayout 部分-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:layout_gravity="bottom"
                android:background="#fff"
                android:orientation="horizontal">

                <SearchView
                    android:layout_width="30dp"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:background="#fff" />

                <android.support.design.widget.TabLayout
                    android:id="@+id/tabLayout_brand"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_gravity="bottom"
                    android:layout_weight="1"
                    android:background="#fff"
                    app:tabIndicatorColor="#000"
                    app:tabMode="scrollable"
                    app:tabTextColor="#ccc" />
            </LinearLayout>
        </android.support.design.widget.CollapsingToolbarLayout>

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

    <include layout="@layout/content_scrolling" />
    <!--<android.support.v4.view.ViewPager-->
        <!--android:id="@+id/viewpager_brand"-->
        <!--android:layout_width="match_parent"-->
        <!--android:layout_height="match_parent"-->
        <!--app:layout_behavior="@string/appbar_scrolling_view_behavior" />-->
</android.support.design.widget.CoordinatorLayout>

  

CoordinatorLayout+TabLayout+ViewPager

原文:http://www.cnblogs.com/yangxiu/p/6246057.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!