<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#33C8C8A9"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="400sp"
android:fitsSystemWindows="true"
android:theme="@style/Theme.AndroidStudy">
<!--本次重点关注这里 CollapsingToolbarLayout -->
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background1"
android:fitsSystemWindows="true"
app:contentScrim="#FF6F8FF3"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/question_image"
android:layout_width="wrap_content"
android:layout_height="400sp"
app:layout_collapseMode="parallax" />
<!-- android:scaleType="centerCrop"-->
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="45sp"
app:layout_collapseMode="pin"
app:navigationIcon="@drawable/back"
app:popupTheme="@style/Theme.AndroidStudy"
app:title="标题"
app:titleTextColor="@color/white">
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
CollapsingToolbarLayout的使用
于 2022-03-13 23:03:41 首次发布