2017-04-19 41 views
4

我有一个布局如下第一隐藏中间鉴于协调布局

  • 布局1
  • 布局2
  • 滚动型

滚动时我需要布局2先消失然后布局1。比如看下面的gif中间视图先消失然后顶视图消失。我怀疑我需要一些自定义行为代码,但不知道从哪里开始。

enter image description here

这里是我当前XML

<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:fitsSystemWindows="true" 
tools:context="com.example.chamoda.coordinatelayoutdemo.ScrollingActivity"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/app_bar" 
    android:layout_width="match_parent" 
    android:layout_height="180dp" 
    android:fitsSystemWindows="true" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="90dp" 
     android:background="@color/colorAccent" 
     app:layout_scrollFlags="scroll" > 

    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="90dp" 
     android:background="@color/colorPrimary" 
     app:layout_scrollFlags="scroll" > 

    </LinearLayout> 

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

<android.support.v4.widget.NestedScrollView 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" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.example.chamoda.coordinatelayoutdemo.ScrollingActivity" 
    tools:showIn="@layout/activity_scrolling"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_margin="@dimen/text_margin" 
     android:text="@string/large_text" /> 

</android.support.v4.widget.NestedScrollView> 

如何归档使用协调布局动画?

回答