- "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"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <androidx.constraintlayout.widget.Guideline
- android:id="@+id/guide_line"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- app:layout_constraintGuide_percent="0.67" />
-
- <androidx.cardview.widget.CardView
- android:id="@+id/card"
- android:layout_width="0dp"
- android:layout_height="0dp"
- app:cardBackgroundColor="@android:color/holo_orange_light"
- app:cardCornerRadius="20dp"
- app:layout_constraintDimensionRatio="1:1"
- app:layout_constraintEnd_toEndOf="@id/guide_line"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent">
-
- <androidx.appcompat.widget.AppCompatImageView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop"
- android:src="@drawable/ic_launcher_foreground" />
- androidx.cardview.widget.CardView>
-
-
- <androidx.cardview.widget.CardView
- android:id="@+id/v1"
- android:layout_width="0dp"
- android:layout_height="0dp"
- app:cardBackgroundColor="@android:color/holo_green_light"
- app:cardCornerRadius="20dp"
- app:layout_constraintBottom_toTopOf="@id/v2"
- app:layout_constraintDimensionRatio="1:1"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="@id/guide_line">
-
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop"
- android:src="@drawable/ic_launcher_foreground" />
- androidx.cardview.widget.CardView>
-
- <androidx.cardview.widget.CardView
- android:id="@+id/v2"
- android:layout_width="0dp"
- android:layout_height="0dp"
- app:cardBackgroundColor="@android:color/holo_red_light"
- app:cardCornerRadius="20dp"
- app:layout_constraintDimensionRatio="1:1"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="@id/guide_line"
- app:layout_constraintTop_toBottomOf="@id/v1">
-
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop"
- android:src="@drawable/ic_launcher_foreground" />
- androidx.cardview.widget.CardView>
- androidx.constraintlayout.widget.ConstraintLayout>
约束布局里面,用到match_parent的地方,可以考虑换成0dp试试。