Ich habe einige Probleme bei der Implementierung der neuen CollapsingToolbarLayout
. Scrollen, erweitern und reduzieren funktioniert gut, aber meine ImageView
(egal, welche Art von Ressource ich eingestellt) umfasst nicht die volle Höhe der erweiterten Symbolleiste. Siehe hier:ImageView in CollapsingToolbarLayout deckt nicht die volle Höhe ab?
Hier stelle ich android:src="@color/red"
auf dem Bild Sicht, aber es deckt nicht die reale Werkzeugleiste. Es funktioniert auch nicht mit Bitmaps. Ich stelle mein Layout unten ein.
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- content -->
<android.support.design.widget.CoordinatorLayout
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_height="@dimen/appbar_expanded_height"
android:layout_width="match_parent"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
app:contentScrim="?attr/colorPrimary"
android:fitsSystemWindows="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:src="@color/red_600"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
app:layout_collapseMode="pin"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<!-- I load fragments here -->
<FrameLayout
android:id="@+id/fragment_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
<!-- nav drawer -->
<fragment
android:layout_width="@dimen/drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>
Mir scheint, dass der einzige Unterschied zum Beispiel der Käse-Chris Banes-App, ist, dass ich app:layout_behavior
zu einem FrameLayout
gebe. Innerhalb dieses Rahmens lade ich jedoch Fragmente, die eine NestedScrollView
als Root-Ansicht haben, und das scheint gut zu funktionieren.
Ich habe genau das gleiche Problem, bei dem mein Bild Ansicht immer unterhalb der Symbolleiste ist. Ich bin mir nicht sicher, ob ich verstehe, wie Sie das behoben haben. – alextk
Ich habe das android: background-Attribut jeder Symbolleiste entfernt, sowohl in Stilen als auch in der Layout-Datei. – natario