首页 > 解决方案 > 圆角方形背景形状,右上角有切出的圆圈

问题描述

我需要创建具有如下设计的项目列表,

在此处输入图像描述

背景多有那个右上角的圆形雕刻图标来排列。

标签: androidandroid-layout

解决方案


在此处输入图像描述

尝试这个....

 <?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="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/white">

        <RelativeLayout
            android:id="@+id/view"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_marginTop="24dp"
            android:layout_marginEnd="24dp"
            android:background="@drawable/roundcorner"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <RelativeLayout
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@drawable/round"
            app:layout_constraintBottom_toTopOf="@+id/view"
            app:layout_constraintEnd_toEndOf="@+id/view"
            app:layout_constraintStart_toEndOf="@+id/view"
            app:layout_constraintTop_toTopOf="@+id/view" />

    </androidx.constraintlayout.widget.ConstraintLayout>

圆形.xml

<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="oval"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#c20586"/>
<stroke android:width="5dp"
    android:color="@android:color/white"/>
</shape>

圆角.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ffa800" />
    <corners android:radius="10dp" />
</shape>

我希望它有帮助..


推荐阅读