在协调布局中首先隐藏中间视图

5
我有一个如下的布局:
  • Layout1
  • Layout2
  • ScrollView
当滚动时,我需要Layout2先消失,然后是Layout1。例如,查看以下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>

我该如何使用坐标布局来存档动画?

遇到了同样的问题。你解决了吗? - Nikita Shavrin
1个回答

0

谢谢,但是我没有找到对我完全有用的东西。我发现在CollapsingToolbarLayout中的每个用例都会先移动顶部布局。也许我错过了什么? - chamoda

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接