实现类似于优惠券的布局

先上一个示例图
下面就是实现的方式了

xml界面,我把界面放在了recyclerview里面,这里就不展示了
里面布局可以自行更改

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:paddingBottom="10dp"
    android:background="@drawable/my_relativelayout_shape">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:orientation="vertical">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

            <TextView
                android:id="@+id/tv_agreement_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="28dp"
                android:text="周杰伦的就业协议"
                android:textColor="#333333"
                android:textSize="15sp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <ImageView
                android:id="@+id/iv_agreement_search"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:layout_marginLeft="15dp"
                android:src="@mipmap/agreement_manage_search"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toRightOf="@+id/tv_agreement_name"
                app:layout_constraintTop_toTopOf="parent" />

            <ImageView
                android:id="@+id/iv_agreement_record"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:layout_marginLeft="15dp"
                android:src="@mipmap/agreement_manage_record"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toRightOf="@id/iv_agreement_search"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/tv_audit_T_or_F"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="23dp"
                android:textSize="14sp"
                android:textColor="#2D82FF"
                android:text="审核通过"/>
        </androidx.constraintlayout.widget.ConstraintLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.5"
            android:gravity="center"
            android:orientation="horizontal">

            <View
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:background="@drawable/shape_bg_semi_circle_top" />

            <View
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/shape_bg_dotted_line"
                android:layerType="software" />

            <View
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:background="@drawable/shape_bg_semi_circle_bottom" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="2"
            android:orientation="vertical">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="28dp"
                    android:text="资料状态"
                    android:textColor="#666666"
                    android:textSize="14sp"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <TextView
                    android:id="@+id/tv_information_status"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="23dp"
                    android:text=""
                    android:textColor="#333333"
                    android:textSize="14sp"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />
            </androidx.constraintlayout.widget.ConstraintLayout>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="28dp"
                    android:text="审核人员"
                    android:textColor="#666666"
                    android:textSize="14sp"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <TextView
                    android:id="@+id/tv_audit_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="23dp"
                    android:text=""
                    android:textColor="#333333"
                    android:textSize="14sp"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />
            </androidx.constraintlayout.widget.ConstraintLayout>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="28dp"
                    android:text="上传时间"
                    android:textColor="#666666"
                    android:textSize="14sp"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <TextView
                    android:id="@+id/tv_upload_time"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="23dp"
                    android:text=""
                    android:textColor="#333333"
                    android:textSize="14sp"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />
            </androidx.constraintlayout.widget.ConstraintLayout>
        </LinearLayout>
    </LinearLayout>
</FrameLayout>

下面是两个半圆和一个中间虚线的shape(如果需要更改半圆的方向修改corners中的属性即可)

右半圆:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid
        android:color="@color/gray"/>
    <corners
        android:topLeftRadius="0dp"
        android:topRightRadius="500dp"
        android:bottomLeftRadius="0dp"
        android:bottomRightRadius="500dp"/>
</shape>

左半圆:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <solid
        android:color="@color/gray"/>
    <corners
        android:topLeftRadius="500dp"
        android:topRightRadius="0dp"
        android:bottomLeftRadius="500dp"
        android:bottomRightRadius="0dp"/>
</shape>

虚线:

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:toDegrees="0">
    <shape
        android:shape="line">
        <stroke
            android:width="1dp"
            android:color="#ff9999"
            android:dashGap="5dp"
            android:dashWidth="5dp"/>
    </shape>
</rotate>

\color{red}{半圆的填充色与背景色相同即可实现透明}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容