2017-04-19 3 views
4

Ich habe ein Layout alsHiding mittlere Ansicht zuerst in Koordinator Layout

folgt
  • Layout1
  • Layout2
  • Scroll

Beim Scrollen ich brauche Layout2 zuerst verschwinden dann Layout1. Zum Beispiel schauen Sie sich die folgende gif Mittelansicht verschwinden zuerst dann Draufsicht verschwinden. Ich vermute, ich brauche einen benutzerdefinierten Verhaltenscode, weiß aber nicht, wo ich anfangen soll.

enter image description here

Hier ist meine aktuelle 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> 

Wie archiviere ich diese Animation Layout mit koordinieren?

Antwort

0

Sie können CollapsingToolbarLayout und Toolbar verwenden, um es zu machen. Bitte sehen Sie diese tolle Anleitung für weitere Informationen:

https://inthecheesefactory.com/blog/android-design-support-library-codelab/en

+0

Danke, aber ich kann nichts hilfreich meinen genauen Anwendungsfall finden. Jeder Anwendungsfall, den ich in CollapsingToolbarLayout gefunden habe, verschiebt zuerst das oberste Layout. Kann mir etwas fehlen? – chamoda

Verwandte Themen