gpt4 book ai didi

android - 透明阴影 View

转载 作者:行者123 更新时间:2023-11-30 01:46:21 25 4
gpt4 key购买 nike

我正在尝试像在 google play 应用程序中那样实现透明阴影。当你向下滚动时,瓷砖位于阴影后面,但你可以看到它们扔掉了它。请在此处查看示例图片:

enter image description here

我创建了一个 View ,我可以通过

添加到布局中
<include layout="@layout/toolbar_shadow" />

toolbar_shadow.xml

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

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/shadow"
/>
</LinearLayout>

影子.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@android:color/transparent"
android:centerColor="#33333333"
android:endColor="#aa666666"


android:angle="90" />
</shape>

我得到的是一个不透明的影子。当一个方 block 在它后面移动时,它会被白色/灰色*覆盖。

*endColor="#aa666666"来自 shadow.xml

有人可以帮我吗?

最佳答案

试试这个,但根据需要更改渐变颜色

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="270"
android:endColor="#0eb0a0"
android:startColor="#0e9083">
</gradient>
</shape>

或者只是将工具栏放入 appbarlayout

    <android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@null"
android:fitsSystemWindows="true"
app:elevation="3dp">

<include layout="@layout/toolbar"/>

</android.support.design.widget.AppBarLayout>

关于android - 透明阴影 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33662944/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com