CollapsingToolbarLayoutは、最大で2つの直接チャイルズが含まれていてもよいです。
- ビュー/のViewGroupと
- ツールバー
あなたが/非表示を表示したい場合はビュー/のViewGroup拡大/縮小時に、あなたは最初の子としてビュー/のViewGroupを入れておく必要がありますツールバーの2番目の子としてCollapsingToolbarLayout。私はあなたがそれだけで1つのビューを持っていると考えていた
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="250dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginBottom="32dp"
app:expandedTitleMarginEnd="16dp"
app:expandedTitleMarginStart="70dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/img_group_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/anim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<!-- Content -->
</android.support.design.widget.CoordinatorLayout>
出典
2017-03-23 14:05:03
FAT
:ここ
は実施例です。画像ビューを使用すると、完璧に動作します、ありがとう! –
CollapsingToolbarLayoutは2つの子(画像+ツールバー)を持つことができますが、画像は最初の子でなければならず、折りたたまれると消えます。 – FeelCode