0

I have a CardView with an inner layout which has a different background color than the CardView. I want the inner layout to be aligned to one side of the CardView and take the 2 rounded corners of that side.

enter image description here

 <android.support.v7.widget.CardView
            android:layout_alignParentBottom="true"
            android:layout_marginLeft="@dimen/activity_horizontal_margin"
            android:layout_marginBottom="@dimen/activity_horizontal_margin"
            android:layout_marginRight="30dp"
            app:cardCornerRadius="20dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    android:text="Pediatric Drugs"/>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:padding="10dp"
                    android:background="@color/colorPrimary"
                    >
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="HELLO"
                        android:textColor="@color/white"
                        android:textStyle="bold"
                        />
                </LinearLayout>

            </RelativeLayout>
        </android.support.v7.widget.CardView>
Bialy
  • 905
  • 2
  • 12
  • 22

1 Answers1

0

I resolved the issue by setting a custom background to the inner layout with top & bottom radius values the same as the CardView radius value.

Bialy
  • 905
  • 2
  • 12
  • 22