【发布时间】:2018-07-17 09:15:19
【问题描述】:
我正在使用 CollapsingToolbarLayout 来创建可折叠工具栏。 背景图片按预期淡化为工具栏颜色。 现在,我还想在工具栏标题和副标题折叠时淡化它的文本颜色(从黑色到白色)。 没有 OnOffsetChangedListener 是否有可能做到这一点?
<android.support.design.widget.AppBarLayout
android:id="@+id/layout_bar"
android:layout_width="match_parent"
android:layout_height="210dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@color/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="true">
<ImageView
android:id="@+id/fadingImage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="80dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_collapseMode="pin"
app:navigationIcon="@drawable/ic_arrow_back">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Information"
android:textColor="@android:color/black"
android:textSize="24sp" />
<TextView
android:id="@+id/subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:fontFamily="sans-serif-light"
android:text="Message List"
android:textSize="17sp" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
【问题讨论】:
-
看看this
-
我将如何在 OnOffsetChangedListener 中使用颜色淡入/更改为较暗的色调来执行此操作?谢谢