gpt4 book ai didi

android - 带有阴影的弯曲 android 工具栏

转载 作者:行者123 更新时间:2023-12-04 02:44:40 25 4
gpt4 key购买 nike

我需要为 Toolbar 或 CardView 提供弯曲的底 View 。

我试过的:

bg_toolbar.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" />
</item>
<item
android:bottom="0dp"
android:left="-100dp"
android:right="-100dp"
android:top="-80dp">
<shape android:shape="oval">
<solid android:color="@color/colorAccent" />
</shape>
</item>
</layer-list>

将此设置为工具栏的背景会使应用栏的高度(阴影)无效。此外,如果将此背景应用于 CardView 背景设置但阴影不是根据背景的形状。

见下图,我希望阴影环绕曲线。

Problem is clear in the image

最佳答案

我已经使用 arcView 完成了这个

依赖实现 'com.github.florent37:shapeofview:1.3.2'

<com.github.florent37.shapeofview.shapes.ArcView
android:layout_width="match_parent"
android:layout_height="155dp"
android:elevation="5.0dp"
app:shape_arc_cropDirection="outside"
app:shape_arc_height="35dp"
app:shape_arc_position="bottom">

<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="155dp"
android:background="@color/colorPrimary"
android:elevation="5dp" />

</com.github.florent37.shapeofview.shapes.ArcView>

检查附加的图像

enter image description here

关于android - 带有阴影的弯曲 android 工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57723295/

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