我正在尝试在我的应用中创建以下设计.
它是主UI上面的叠加层.尝试使用主UI顶部的布局创建它,其背景为以XML创建的半透明形状.然而,即使阅读了多篇文章,我也无法弄明白.
我尝试了以下方法,但它没有用.创建一个200dp笔划的环形,并将其设置为imageview的源,然后将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>
Run Code Online (Sandbox Code Playgroud)
叠加布局:
<?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>
Run Code Online (Sandbox Code Playgroud)
有关如何执行此操作或代码的任何指示都非常有用.