android toolbar 颜色渐变,android – 如何使渐变形状留在CollapsingToolbarLayout标题后面...

我一直在玩

Chris Bane’s Cheesesquare example application关于折叠工具栏布局,我在折叠工具栏上添加标题背后的渐变时,即使背景很亮,标题仍然可读.

该解决方案将渐变“附加”到图像本身而不是“折叠”工具栏的底部.当你向下滚动时,会发生的情况是,随着视线的视线偏离,该渐变将随着图像消失.我想让渐变跟随工具栏折叠(并保持视差效果).

activity_contact_detail.xml

android:id="@+id/appbar"

android:layout_width="match_parent"

android:layout_height="@dimen/detail_backdrop_height"

android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

android:id="@+id/collapsing_toolbar"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:contentScrim="?attr/colorPrimary"

app:expandedTitleMarginEnd="64dp"

app:expandedTitleMarginStart="48dp"

app:layout_scrollFlags="scroll|exitUntilCollapsed">

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_collapseMode="parallax">

android:id="@+id/backdrop"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:scaleType="centerCrop"

android:src="@drawable/woman"/>

android:layout_width="match_parent"

android:layout_height="?actionBarSize"

android:layout_gravity="bottom"

android:background="@drawable/backdrop_bg"/>

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

app:layout_collapseMode="pin"

app:popupTheme="@style/ThemeOverlay.AppCompat.Light"

/>

...

android:layout_width="match_parent"

android:layout_height="?actionBarSize"

android:background="@drawable/backdrop_bg"

app:layout_anchor="@id/appbar"

app:layout_anchorGravity="bottom"/>

backdrop_bg.xml

xmlns:android="http://schemas.android.com/apk/res/android"

android:shape="rectangle">

android:angle="90"

android:endColor="#0000"

android:startColor="#303F9F"

android:type="linear"/>

非常欢迎任何帮助!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值