我正在尝试在我的应用程序中创建以下设计。
它覆盖在主 UI 之上。尝试使用主 UI 顶部的布局创建它,其背景是在 XML 中创建的半透明形状。但是,即使在阅读了多个帖子之后,我也无法弄清楚。
我尝试了以下方法,但没有奏效。创建一个具有 200dp 笔划的环形并将其设置为图像视图的源,然后将 scaletype 设置为 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>
有关如何执行此操作或代码的任何指示都会非常有帮助。