Android: Lineare Darstellung reduzieren anstatt Symbolleiste reduzieren
Ich versuche, eine Master / Detail-Transaktion in einem einzelnen Fragment zu erstellen. Ich dachte daran, LinearLayout als Container für meinen Edittext für meinen Header zu verwenden. Dann ein RecyclerView für Details.
Wie würde man das Ein- / Ausblenden von LinearLayout ähnlich dem CollapsingToolbar-Effekt implementieren?
Hier ist ein Screenshot von dem, was ich versuche.
Mein XML-Code bisher.
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/colorAccent"
android:padding="@dimen/activity_horizontal_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_date_range_black_24dp"
android:tint="@android:color/darker_gray" />
<android.support.v4.widget.Space
android:layout_width="@dimen/activity_horizontal_margin"
android:layout_height="wrap_content" />
<android.support.design.widget.TextInputLayout
android:id="@+id/date_til"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Date">
<android.support.design.widget.TextInputEditText
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cursorVisible="false"
android:focusable="false"
android:longClickable="false" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_store_black_24dp"
android:tint="@android:color/darker_gray" />
<android.support.v4.widget.Space
android:layout_width="@dimen/activity_horizontal_margin"
android:layout_height="wrap_content" />
<android.support.design.widget.TextInputLayout
android:id="@+id/store_til"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Store">
<android.support.design.widget.TextInputEditText
android:id="@+id/store"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_place_black_24dp"
android:tint="@android:color/darker_gray" />
<android.support.v4.widget.Space
android:layout_width="@dimen/activity_horizontal_margin"
android:layout_height="wrap_content" />
<android.support.design.widget.TextInputLayout
android:id="@+id/location_til"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Location" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layoutManager="LinearLayoutManager"
tools:listitem="@layout/list_car" />
</LinearLayout>
Auch nicht sicher, ob dies mit der CollapsingToolbar möglich ist, da in der Toolbar meistens nur ImageView ausgeblendet ist.
Schätzen Sie jede Hilfe.
UPDATE: Grundsätzlich möchte ich hier in der Lage sein, die Header-Ansicht beim Scrollen zu reduzieren. Erweitern Sie dann beim Scrollen nach unten.