2
実際に折り畳まずにツールバーの色を変えようとしています(高さを変えたくありません)。最初は1色にしてから、スクロールすると別の色に変わります。その後、上にスクロールすると元の色に戻ります。折りたたまずにスクロールのツールバーの色を変更します。
私はスクロールの色を変更することができましたが、高さの変更に関連してのみ変更できました。私は、ツールバー、CollapsingToolbarLayoutとAppBarLayoutにminHeightを設定しようとしましたが、残念なことに運はありません。
私はこれを手動で行うことができます(スクロール変更時に色をアニメーション化することができます)が、私はデザインライブラリを使用して最初にそれを除外したいと考えています。
これは私がこれまで持っているものです:事前に
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/app_secondary_darker">
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:fitsSystemWindows="true"
app:contentScrim="@color/white"
app:layout_scrollFlags="scroll">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="400dp"
android:text="Abc"
android:background="@color/grey_light"/>
<TextView
android:layout_width="match_parent"
android:layout_height="400dp"
android:text="Def"
android:background="@color/red_dark"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
ありがとう!