几天来我一直在寻找如何制作这些颜色阴影和立面效果,但哪里都不清楚。做这件事最简单的方法是什么?


发布于 2021-01-19 03:44:11
在视图类中提供了起始API28 (Pie)、View#setOutlineAmbientShadowColor(整色)和View#setOutlineSpotShadowColor(整色)。
如果在视图上使用高程,则可以使用这两种方法来更改阴影的颜色。
你可以使用CardView来生成阴影。
发布于 2021-01-19 05:31:40
最简单的方法之一:
CardView
卡片视图以及支持标高。
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardBackgroundColor="@android:color/white"
app:cardElevation="20dp" />注意:在卡片视图的背景中,只有你可以使用简单的颜色。如果你想要更多的选项,你可以将你的图片或可绘制的图片放在子背景中。
如下所示:
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardElevation="20dp" >
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/flag_peru" <= use this options
>
.
.
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>https://stackoverflow.com/questions/65780823
复制相似问题