CoordinatorLayout+TabLayout+ViewPager

时间:2023-03-08 16:29:38
CoordinatorLayout+TabLayout+ViewPager
<?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>