【发布时间】:2020-10-23 20:32:02
【问题描述】:
我想让我的 ImageView 在底部弯曲并带有阴影效果。
类似于这张图片
但我不知道该怎么做。
每当我在 Google 或 StackOverflow 上搜索时,它都会向我显示与弯角相关的结果,但我希望底部有弯曲的边缘。
【问题讨论】:
标签: android imageview shapes cardview
我想让我的 ImageView 在底部弯曲并带有阴影效果。
类似于这张图片
但我不知道该怎么做。
每当我在 Google 或 StackOverflow 上搜索时,它都会向我显示与弯角相关的结果,但我希望底部有弯曲的边缘。
【问题讨论】:
标签: android imageview shapes cardview
你可以使用layer-list
例如,
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-150dp"
android:right="-150dp"
android:top="-200dp">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#C72C2F" />
</shape>
</item>
</layer-list>
它是这样显示的。
然后在后台使用这个,
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
app:layout_constraintTop_toTopOf="parent"
android:background="@drawable/round"
android:elevation="30dp"
android:layout_width="match_parent"
android:layout_height="700dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
它是这样的。
还有做阴影效果,我用android:elevation做阴影,如果你增加值,它可以做更多的深度。
显然为显示图像添加了图像视图。我相信你可以做到。
【讨论】:
Glide?