我正在尝试在我的应用程序中创建以下设计。
这是主UI上的叠加层。我正在尝试使用一个布局来创建它,该布局的背景是在XML中创建的半透明形状。然而,即使阅读了多篇文章,我仍然无法弄清楚它的实现方法。
我尝试了以下方法,但没有成功。创建了一个带有200dp描边的环形形状,并将其设置为图像视图的源,然后将比例类型设置为centerCrop,但形状并未像位图一样缩放。
形状XML:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="2"
android:useLevel="false" >
<solid android:color="@android:color/transparent" />
<stroke
android:width="200dp"
android:color="#80000000" />
</shape>
覆盖式布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/onboarding_background"
android:scaleType="centerCrop"/>
</RelativeLayout>
任何关于如何做到这一点或者提供代码的指针都将非常有帮助。