CoordinatorLayout + AppBarLayout+ToolBar 实现向上滚动隐藏 ToolBar

【需求】

图片.png

【传送门】https://www.jianshu.com/p/9e126f3538a0
【xml 布局 】

<?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"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent">

<android.support.design.widget.CoordinatorLayout
    android:fitsSystemWindows="false"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/shell_appbarlayout_style"
        app:elevation="0dp">

        <android.support.v7.widget.Toolbar
            app:layout_scrollFlags="scroll|enterAlways"
            android:id="@+id/toolbar"
            android:paddingTop="6dp"
            android:layout_width="match_parent"
            android:layout_height="35dp">

        <ImageView
            android:id="@+id/iv_home_tab_logo"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/shell_home_actionbar_logo"/>

        </android.support.v7.widget.Toolbar>


        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        <android.support.design.widget.TabLayout
            android:id="@+id/tbl"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabIndicatorColor="@color/colorAccent"
            app:tabPaddingEnd="6dp"
            app:tabPaddingStart="6dp"
            app:tabSelectedTextColor="@color/shell_font_black"
            android:layout_marginRight="35dp"
            app:tabTextColor="@color/shell_font_gray"/>

            <ImageView
                android:id="@+id/iv_home_tab_more"
                android:layout_gravity="end|center_vertical"
                android:background="@color/shell_divide_line_gray"
                android:padding="6dp"
                android:layout_marginRight="8dp"
                android:layout_marginLeft="60dp"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:src="@drawable/shell_home_tab_more"/>

        </FrameLayout>

        <View
            android:id="@+id/view"
            android:layout_width="match_parent"
            android:layout_height="0.5dp"
            android:background="@color/shell_divide_line_gray" />

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

    <LinearLayout
        android:visibility="visible"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        android:orientation="vertical"
        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>
 </LinearLayout>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容