我需要为 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 背景设置但阴影不是根据背景的形状。
见下图,我希望阴影环绕曲线。
最佳答案
我已经使用 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>
检查附加的图像
关于android - 带有阴影的弯曲 android 工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57723295/