将圆角应用于 CardView 内部元素

Applying the rounded corners to a CardView inner element

我有一个带有内部布局的 CardView,它的背景颜色与 CardView 不同。我希望内部布局与 CardView 的一侧对齐,并取该侧的 2 个圆角。

 <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>

我通过为内部布局设置自定义背景解决了这个问题,其顶部和底部半径值与 CardView 半径值相同。