0

everyone. I would like to show only the top two corners of a CardView rounded. I'm trying to do that with a separate layout file. Nothing happens at all. The corners are not rounded.

acitivity_single_xml layout

   <androidx.cardview.widget.CardView
    android:id="@+id/cardView2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="40dp"
    android:background="@drawable/card_radius"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/imageView3">

     ...

   </androidx.cardview.widget.CardView>

card_radius.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="rectangle">
        <corners android:topRightRadius="40dp"
            android:topLeftRadius="40dp"
            android:bottomLeftRadius="0dp"
            android:bottomRightRadius="0dp"></corners>
        <solid android:color="@color/white_real"></solid>
    </shape>
 </item>
Captai-N
  • 1,124
  • 3
  • 15
  • 26
  • 1
    `CardView` handles its own background, and only really does equal corners. If you want to provide your own background, you can simply set it on a `FrameLayout` instead, which is basically all `CardView` is. Alternatively, if you don't necessarily need to use your own drawable, and just need the different corner radii, it might be easier to use `MaterialCardView` instead: https://stackoverflow.com/q/54688737. – Mike M. Jan 02 '23 at 11:05

0 Answers0