Android设计支持库。工具栏动画

时间:2015-07-27 06:37:32

标签: android androiddesignsupport android-support-design

在我的应用程序中,我想使用Google Play应用程序中的标签为工具栏实现快速返回模式。

这是我的活动布局:

<?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.support.design.widget.AppBarLayout
        android:id="@+id/home_app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/home_toolbar"
            style="@style/AppTabStyle"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

        <android.support.design.widget.TabLayout
            android:id="@+id/home_tab_layout"
            style="@style/TabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

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

    <android.support.v4.view.ViewPager
        android:id="@+id/home_view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

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

我在ViewPager中包含了包含RecyclerViews的片段。因此,当RecyclerView滚动到底部并显示其他情况时,一切正常,工具栏隐藏。但是如果我滚动一点RecyclerView,就可能显示工具栏处于错误的状态。

初始状态: Initial state

错误的状态: Wrong state

我想在Google Play中使用工具栏动画。是否可以使用设计支持库?有没有人对这种情况有很好的CoordinatorLayout.Behavior

0 个答案:

没有答案
相关问题