Ich verwende CollapsingToolbarLayout, um Bild in der Symbolleiste meiner Aktivität anzuzeigen, und es funktioniert einwandfrei. Aber manchmal, abhängig vom angezeigten Fragment, möchte ich kein Bild anzeigen. In diesem Fall hätte ich gerne eine normal aussehende Werkzeugleiste. Wenn ich keine Zeichen an imageView übergeben, seine Höhe auf 0 setzen oder seine Sichtbarkeit auf GONE setzen, sieht die Symbolleiste normal aus, mit der Ausnahme, dass kein Titel vorhanden ist. Warum das?CollapsingToolbarLayout zeigt Titel nicht an, wenn kein Bild vorhanden ist
Meine Layout-Datei:
<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"
>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="40dp"
android:background="@color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/transparent"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />