CardView
的结构,如下图所示。为此,我目前正在使用
Constraintlayout
但面临多个问题,即剪辑问题。这是我的代码:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:id="@+id/card_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rotation="-20"
android:layout_marginTop="@dimen/dimen_12"
android:layout_marginStart="@dimen/dimen_25"
app:cardCornerRadius="@dimen/dimen_8"
app:cardElevation="@dimen/dimen_1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:id="@+id/rl_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/top_colored_gradient_dark"
android:padding="@dimen/dimen_12">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/img_one"
android:layout_width="72dp"
android:layout_height="72dp"
android:src="@drawable/blue_social" />
<TextView
android:id="@+id/txt_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/img_one"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dimen_15"
android:textColor="#313131"
android:textSize="@dimen/dimen_14sp"
tools:text="Title Here" />
<TextView
android:id="@+id/txt_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txt_name"
android:layout_centerHorizontal="true"
android:textColor="@color/light_text_color"
android:textSize="@dimen/dimen_11sp"
tools:text="Date" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/card_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardElevation="@dimen/dimen_2"
app:cardUseCompatPadding="true"
app:cardCornerRadius="@dimen/dimen_8"
android:layout_marginEnd="@dimen/dimen_15"
app:layout_constraintEnd_toStartOf="@id/card_third"
app:layout_constraintStart_toEndOf="@id/card_one"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:id="@+id/rl_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/top_colored_gradient_dark"
android:padding="@dimen/dimen_12">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/img_two"
android:layout_width="72dp"
android:layout_height="72dp"
android:src="@drawable/blue_social" />
<TextView
android:id="@+id/txt_name_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/img_two"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dimen_15"
android:textColor="#313131"
android:textSize="@dimen/dimen_14sp"
tools:text="Title Here" />
<TextView
android:id="@+id/txt_date_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txt_name_two"
android:layout_centerHorizontal="true"
android:textColor="@color/light_text_color"
android:textSize="@dimen/dimen_11sp"
tools:text="Date" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/card_third"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardElevation="@dimen/dimen_1"
app:cardCornerRadius="@dimen/dimen_8"
android:layout_marginTop="@dimen/dimen_8"
android:rotation="20"
app:cardUseCompatPadding="true"
app:layout_constraintStart_toEndOf="@id/card_second"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:id="@+id/rl_third"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/top_colored_gradient_dark"
android:padding="@dimen/dimen_12">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/img_third"
android:layout_width="72dp"
android:layout_height="72dp"
android:src="@drawable/blue_social" />
<TextView
android:id="@+id/txt_name_third"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/img_third"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dimen_15"
android:textColor="#313131"
android:textSize="@dimen/dimen_14sp"
tools:text="Title Here" />
<TextView
android:id="@+id/txt_date_third"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txt_name_third"
android:layout_centerHorizontal="true"
android:textColor="@color/light_text_color"
android:textSize="@dimen/dimen_11sp"
tools:text="Date" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
答案 0 :(得分:0)
您可以使用 FrameLayout 而不是约束来像图像中那样堆叠视图。