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

标签 android android-layout android-toolbar cardview

我需要为 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/

相关文章:

android - Facebook SDK for Unity Android - 生成的 list 文件不正确,无法登录

未找到 Android 库

Android AppCompat 工具栏不响应触摸操作项

android - 区分 Google Play Sandbox 购买

java - 配置 SAX 解析器

android - 按下设备的主页键后,如何始终在图标按下时打开当前 Activity

android - tablelayout 中动态添加的行不可见

android - 如何在我的应用程序上实现滑动界面以在左右屏幕之间滑动

android - 为所有 Activity 设置工具栏

android - 使用工具栏导航回父 Activity