如何使 4 个组件适合约束布局,它们周围和之间的 space 相等

How to make 4 Components fit in constrain layout with equal space around and between them

我在 ConstraintLayout 中有 4 个组件(框),但问题是这些组件之间的 space 比它们周围的 space 多 我知道这个问题是因为我给每个单独的组件留了余量,但是有什么解决方法?实现下面给出的设计

以上是我到目前为止所取得的成就。

困扰的主要问题是这 4 个组件之间的 space,它看起来彼此远离而不是紧凑。

这是我的 xml 代码

            <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerInParent="true">

            <androidx.constraintlayout.widget.Guideline
                android:id="@+id/view_horizontal"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                app:layout_constraintGuide_percent="0.5" />
            
            <!--                Top Left-->
            <FrameLayout
                android:id="@+id/frameLayout_top_left"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_constraintBottom_toTopOf="@+id/view_horizontal"
                app:layout_constraintEnd_toStartOf="@+id/frameLayout_top_right"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintHorizontal_chainStyle="packed"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">
                
                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_marginStart="@dimen/_17sdp"
                    android:layout_marginTop="@dimen/_20sdp"
                    android:layout_marginEnd="@dimen/_17sdp"
                    android:layout_marginBottom="@dimen/_18sdp"
                    android:backgroundTint="@color/gradient_end_dashboard"
                    app:cardCornerRadius="20dp"
                    app:cardElevation="5dp"
                    app:cardMaxElevation="5dp" />

                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_marginStart="@dimen/_15sdp"
                    android:layout_marginTop="@dimen/_20sdp"
                    android:layout_marginEnd="@dimen/_15sdp"
                    android:layout_marginBottom="@dimen/_20sdp"
                    android:backgroundTint="@color/white"
                    app:cardCornerRadius="20dp"
                    app:cardElevation="5dp"
                    app:cardMaxElevation="5dp"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

            </FrameLayout>

            <!--                Top Right-->
            <FrameLayout
                android:id="@+id/frameLayout_top_right"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_constraintBottom_toTopOf="@+id/view_horizontal"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/frameLayout_top_left"
                app:layout_constraintTop_toTopOf="parent">
                
                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_marginStart="@dimen/_17sdp"
                    android:layout_marginTop="@dimen/_20sdp"
                    android:layout_marginEnd="@dimen/_17sdp"
                    android:layout_marginBottom="@dimen/_18sdp"
                    android:backgroundTint="@color/gradient_end_dashboard"
                    app:cardCornerRadius="20dp"
                    app:cardElevation="5dp"
                    app:cardMaxElevation="5dp" />

                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_marginStart="@dimen/_15sdp"
                    android:layout_marginTop="@dimen/_20sdp"
                    android:layout_marginEnd="@dimen/_15sdp"
                    android:layout_marginBottom="@dimen/_20sdp"
                    android:backgroundTint="@color/white"
                    app:cardCornerRadius="20dp"
                    app:cardElevation="5dp"
                    app:cardMaxElevation="5dp"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

            </FrameLayout>
            
            <!--                Bottom Left-->
            <FrameLayout
                android:id="@+id/frameLayout_bottom_left"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/frameLayout_bottom_right"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/view_horizontal">
                
                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_marginStart="@dimen/_17sdp"
                    android:layout_marginTop="@dimen/_20sdp"
                    android:layout_marginEnd="@dimen/_17sdp"
                    android:layout_marginBottom="@dimen/_18sdp"
                    android:backgroundTint="@color/gradient_end_dashboard"
                    app:cardCornerRadius="20dp"
                    app:cardElevation="5dp"
                    app:cardMaxElevation="5dp" />

                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_marginStart="@dimen/_15sdp"
                    android:layout_marginTop="@dimen/_20sdp"
                    android:layout_marginEnd="@dimen/_15sdp"
                    android:layout_marginBottom="@dimen/_20sdp"
                    android:backgroundTint="@color/white"
                    app:cardCornerRadius="20dp"
                    app:cardElevation="5dp"
                    app:cardMaxElevation="5dp"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

            </FrameLayout>

            <!--                Bottom Right-->
            <FrameLayout
                android:id="@+id/frameLayout_bottom_right"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/frameLayout_bottom_left"
                app:layout_constraintTop_toBottomOf="@id/view_horizontal">
                
                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_marginStart="@dimen/_17sdp"
                    android:layout_marginTop="@dimen/_20sdp"
                    android:layout_marginEnd="@dimen/_17sdp"
                    android:layout_marginBottom="@dimen/_18sdp"
                    android:backgroundTint="@color/gradient_end_dashboard"
                    app:cardCornerRadius="20dp"
                    app:cardElevation="5dp"
                    app:cardMaxElevation="5dp" />

                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_marginStart="@dimen/_15sdp"
                    android:layout_marginTop="@dimen/_20sdp"
                    android:layout_marginEnd="@dimen/_15sdp"
                    android:layout_marginBottom="@dimen/_20sdp"
                    android:backgroundTint="@color/white"
                    app:cardCornerRadius="20dp"
                    app:cardElevation="5dp"
                    app:cardMaxElevation="5dp"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

            </FrameLayout>
            
        </androidx.constraintlayout.widget.ConstraintLayout>

不需要使用那个GuideLine。您的所有组件必须相互约束以启用每个组件的动态大小(因为您的宽度和高度为 0dp)。组件之间以及组件与屏幕边缘之间的间距可以使用边距来定义:

<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="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/frameLayout_top_left"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="@dimen/full_margin"
        android:layout_marginTop="@dimen/full_margin"
        android:layout_marginEnd="@dimen/half_margin"
        android:layout_marginBottom="@dimen/half_margin"
        android:background="@android:color/black"
        app:layout_constraintBottom_toTopOf="@id/frameLayout_bottom_left"
        app:layout_constraintEnd_toStartOf="@id/frameLayout_top_right"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <FrameLayout
        android:id="@+id/frameLayout_top_right"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="@dimen/half_margin"
        android:layout_marginTop="@dimen/full_margin"
        android:layout_marginEnd="@dimen/full_margin"
        android:layout_marginBottom="@dimen/half_margin"
        android:background="@android:color/black"
        app:layout_constraintBottom_toTopOf="@id/frameLayout_bottom_right"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/frameLayout_top_left"
        app:layout_constraintTop_toTopOf="parent" />

    <FrameLayout
        android:id="@+id/frameLayout_bottom_left"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="@dimen/full_margin"
        android:layout_marginTop="@dimen/half_margin"
        android:layout_marginEnd="@dimen/half_margin"
        android:layout_marginBottom="@dimen/full_margin"
        android:background="@android:color/black"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/frameLayout_bottom_right"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/frameLayout_top_left" />

    <FrameLayout
        android:id="@+id/frameLayout_bottom_right"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="@dimen/half_margin"
        android:layout_marginTop="@dimen/half_margin"
        android:layout_marginEnd="@dimen/full_margin"
        android:layout_marginBottom="@dimen/full_margin"
        android:background="@android:color/black"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/frameLayout_bottom_left"
        app:layout_constraintTop_toBottomOf="@id/frameLayout_top_right" />

</androidx.constraintlayout.widget.ConstraintLayout>

这是我发现的-->

我将你的卡片视图包含在线性和相对的组合中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.5" >

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:background="#242425"
        android:gravity="center"
        android:layout_marginBottom="-19dp"
        android:orientation="vertical" >


        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_marginStart="17dp"
            android:layout_marginTop="20dp"
            android:layout_marginEnd="17dp"
            android:layout_marginBottom="18dp"
            android:backgroundTint="@color/colorPrimary"
            app:cardCornerRadius="20dp"
            app:cardElevation="5dp"
            app:cardMaxElevation="5dp" />

        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
     android:layout_centerInParent="true"
            android:backgroundTint="#FFFFFF"
            android:layout_marginStart="15dp"
            android:layout_marginTop="20dp"
            android:layout_marginEnd="15dp"
            android:layout_marginBottom="40dp"
            app:cardCornerRadius="20dp"
            app:cardElevation="5dp"
            app:cardMaxElevation="5dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:background="#242425"
        android:gravity="center"
        android:layout_marginBottom="-19dp"

        android:orientation="vertical" >


        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_marginStart="17dp"
            android:layout_marginTop="20dp"
            android:layout_marginEnd="17dp"
            android:layout_marginBottom="18dp"
            android:backgroundTint="@color/colorPrimary"
            app:cardCornerRadius="20dp"
            app:cardElevation="5dp"
            app:cardMaxElevation="5dp" />

        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_centerInParent="true"
            android:backgroundTint="#FFFFFF"
            android:layout_marginStart="15dp"
            android:layout_marginTop="20dp"
            android:layout_marginEnd="15dp"
            android:layout_marginBottom="40dp"
            app:cardCornerRadius="20dp"
            app:cardElevation="5dp"
            app:cardMaxElevation="5dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </RelativeLayout>

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.5" >

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:background="#242425"
        android:gravity="center"
        android:orientation="vertical" >



        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_marginStart="17dp"
            android:layout_marginTop="20dp"
            android:layout_marginEnd="17dp"
            android:layout_marginBottom="18dp"
            android:backgroundTint="@color/colorPrimary"
            app:cardCornerRadius="20dp"
            app:cardElevation="5dp"
            app:cardMaxElevation="5dp" />

        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_centerInParent="true"
            android:backgroundTint="#FFFFFF"
            android:layout_marginStart="15dp"
            android:layout_marginTop="20dp"
            android:layout_marginEnd="15dp"
            android:layout_marginBottom="40dp"
            app:cardCornerRadius="20dp"
            app:cardElevation="5dp"
            app:cardMaxElevation="5dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:background="#242425"
        android:gravity="center"
        android:orientation="vertical" >

        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_marginStart="17dp"
            android:layout_marginTop="20dp"
            android:layout_marginEnd="17dp"
            android:layout_marginBottom="18dp"
            android:backgroundTint="@color/colorPrimaryDark"
            app:cardCornerRadius="20dp"
            app:cardElevation="5dp"
            app:cardMaxElevation="5dp" />

        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_centerInParent="true"
            android:backgroundTint="#FFFFFF"
            android:layout_marginStart="15dp"
            android:layout_marginTop="20dp"
            android:layout_marginEnd="15dp"
            android:layout_marginBottom="40dp"
            app:cardCornerRadius="20dp"
            app:cardElevation="5dp"
            app:cardMaxElevation="5dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </RelativeLayout>
</LinearLayout>

输出

尝试使用相对布局而不是框架布局,并在第二个 cardView

内移动您的 layout/imageview
<RelativeLayout
    android:id="@+id/rl_top_left"
    android:layout_height="0dp"
    android:layout_width="0dp"
    app:layout_constraintBottom_toTopOf="@+id/rl_bottom_left"
    app:layout_constraintEnd_toStartOf="@+id/rl_top_right"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <androidx.cardview.widget.CardView
        android:backgroundTint="#163042"
        android:layout_gravity="center"
        android:layout_height="match_parent"
        android:layout_marginBottom="3dp"
        android:layout_marginEnd="7dp"
        android:layout_marginStart="7dp"
        android:layout_marginTop="7dp"
        android:layout_width="match_parent"
        app:cardCornerRadius="20dp"
        app:cardElevation="5dp"
        app:cardMaxElevation="5dp" />

    <androidx.cardview.widget.CardView
        android:backgroundTint="#ffffff"
        android:layout_gravity="center"
        android:layout_height="match_parent"
        android:layout_margin="7dp"
        android:layout_width="match_parent"
        app:cardCornerRadius="20dp"
        app:cardElevation="5dp"
        app:cardMaxElevation="5dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:elevation="10dp"
            android:layout_gravity="center"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:layout_width="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:layout_gravity="center"
                android:layout_height="40dp"
                android:layout_width="40dp"
                android:src="@drawable/ic_apple" />

            <TextView
                android:layout_gravity="center"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_width="wrap_content"
                android:text="Some Text"
                android:textColor="#abcdef"
                android:textSize="22sp"
                android:textStyle="bold" />

            <TextView
                android:layout_gravity="center"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_width="wrap_content"
                android:text="sub text"
                android:textColor="#009688"
                android:textSize="14sp"
                android:textStyle="bold" />


        </LinearLayout>

    </androidx.cardview.widget.CardView>

</RelativeLayout>

<RelativeLayout
    android:id="@+id/rl_top_right"
    android:layout_height="0dp"
    android:layout_width="0dp"
    app:layout_constraintBottom_toTopOf="@+id/rl_bottom_right"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toEndOf="@+id/rl_top_left"
    app:layout_constraintTop_toTopOf="parent">

    <androidx.cardview.widget.CardView
        android:backgroundTint="#163042"
        android:layout_gravity="center"
        android:layout_height="match_parent"
        android:layout_marginBottom="3dp"
        android:layout_marginEnd="7dp"
        android:layout_marginStart="7dp"
        android:layout_marginTop="7dp"
        android:layout_width="match_parent"
        app:cardCornerRadius="20dp"
        app:cardElevation="5dp"
        app:cardMaxElevation="5dp" />

    <androidx.cardview.widget.CardView
        android:backgroundTint="#ffffff"
        android:layout_gravity="center"
        android:layout_height="match_parent"
        android:layout_margin="7dp"
        android:layout_width="match_parent"
        app:cardCornerRadius="20dp"
        app:cardElevation="5dp"
        app:cardMaxElevation="5dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:elevation="10dp"
            android:layout_gravity="center"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:layout_width="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:layout_gravity="center"
                android:layout_height="40dp"
                android:layout_width="40dp"
                android:src="@drawable/ic_apple" />

            <TextView
                android:layout_gravity="center"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_width="wrap_content"
                android:text="Some Text"
                android:textColor="#abcdef"
                android:textSize="22sp"
                android:textStyle="bold" />

            <TextView
                android:layout_gravity="center"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_width="wrap_content"
                android:text="sub text"
                android:textColor="#009688"
                android:textSize="14sp"
                android:textStyle="bold" />


        </LinearLayout>

    </androidx.cardview.widget.CardView>

</RelativeLayout>

<RelativeLayout
    android:id="@+id/rl_bottom_left"
    android:layout_height="0dp"
    android:layout_width="0dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@+id/rl_bottom_right"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/rl_top_left">

    <androidx.cardview.widget.CardView
        android:backgroundTint="#163042"
        android:layout_gravity="center"
        android:layout_height="match_parent"
        android:layout_marginBottom="3dp"
        android:layout_marginEnd="7dp"
        android:layout_marginStart="7dp"
        android:layout_marginTop="7dp"
        android:layout_width="match_parent"
        app:cardCornerRadius="20dp"
        app:cardElevation="5dp"
        app:cardMaxElevation="5dp" />

    <androidx.cardview.widget.CardView
        android:backgroundTint="#ffffff"
        android:layout_gravity="center"
        android:layout_height="match_parent"
        android:layout_margin="7dp"
        android:layout_width="match_parent"
        app:cardCornerRadius="20dp"
        app:cardElevation="5dp"
        app:cardMaxElevation="5dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:elevation="10dp"
            android:layout_gravity="center"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:layout_width="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:layout_gravity="center"
                android:layout_height="40dp"
                android:layout_width="40dp"
                android:src="@drawable/ic_apple" />

            <TextView
                android:layout_gravity="center"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_width="wrap_content"
                android:text="Some Text"
                android:textColor="#abcdef"
                android:textSize="22sp"
                android:textStyle="bold" />

            <TextView
                android:layout_gravity="center"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_width="wrap_content"
                android:text="sub text"
                android:textColor="#009688"
                android:textSize="14sp"
                android:textStyle="bold" />


        </LinearLayout>

    </androidx.cardview.widget.CardView>

</RelativeLayout>

<RelativeLayout
    android:id="@+id/rl_bottom_right"
    android:layout_height="0dp"
    android:layout_width="0dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toEndOf="@+id/rl_bottom_left"
    app:layout_constraintTop_toBottomOf="@+id/rl_top_right">

    <androidx.cardview.widget.CardView
        android:backgroundTint="#163042"
        android:layout_gravity="center"
        android:layout_height="match_parent"
        android:layout_marginBottom="3dp"
        android:layout_marginEnd="7dp"
        android:layout_marginStart="7dp"
        android:layout_marginTop="7dp"
        android:layout_width="match_parent"
        app:cardCornerRadius="20dp"
        app:cardElevation="5dp"
        app:cardMaxElevation="5dp" />

    <androidx.cardview.widget.CardView
        android:backgroundTint="#ffffff"
        android:layout_gravity="center"
        android:layout_height="match_parent"
        android:layout_margin="7dp"
        android:layout_width="match_parent"
        app:cardCornerRadius="20dp"
        app:cardElevation="5dp"
        app:cardMaxElevation="5dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:elevation="10dp"
            android:layout_gravity="center"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:layout_width="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:layout_gravity="center"
                android:layout_height="40dp"
                android:layout_width="40dp"
                android:src="@drawable/ic_apple" />

            <TextView
                android:layout_gravity="center"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_width="wrap_content"
                android:text="Some Text"
                android:textColor="#abcdef"
                android:textSize="22sp"
                android:textStyle="bold" />

            <TextView
                android:layout_gravity="center"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_width="wrap_content"
                android:text="sub text"
                android:textColor="#009688"
                android:textSize="14sp"
                android:textStyle="bold" />


        </LinearLayout>

    </androidx.cardview.widget.CardView>

</RelativeLayout>