带有阴影的弯曲android工具栏 [英] Curved android toolbar with shadow
本文介绍了带有阴影的弯曲android工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要为工具栏或CardView提供弯曲的底视图.
I need to have a curved bottom view for Toolbar or CardView.
我尝试过的事情:
bg_toolbar.xml
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,则设置了背景,但阴影与背景的形状不符.
Setting this as a background to toolbar voids the appbar elevation (shadow). Also if this background is applied to a CardView background is set but the shadow is not according to shape of the background.
请参见下图,我希望阴影可以环绕曲线.
See the below image, I want the shadow to wrap around the curve.
推荐答案
我已使用arcView完成此操作
I have done this using arcView
依赖实现'com.github.florent37:shapeofview:1.3.2'
Dependency implementation '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工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文