如何为某些子成员设置 cardview 的圆角半径?

How to set corner radius for cardview with some child members?

第一张图片是我的结果,我想让它看起来像第二张。我试图给出角半径,但它没有出现在屏幕上。我不知道是什么问题,而且父 cardview 也没有显示海拔。

提前谢谢你。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    tools:context="com.software_solutions.optimus_tech_project201709.CourseSelect.CourseSelectionActivity">

    <Button
        android:id="@+id/register"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="Register" />


    <Button
        android:id="@+id/you"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="you" />

    <ImageView
        android:id="@+id/dialogImageView"
        android:layout_width="match_parent"
        android:layout_height="220dp"
        android:scaleType="fitXY"
        android:src="@drawable/dialog"
        android:text="Hello" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/dialogImageView"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="-180dp"
        android:gravity="center"
        android:orientation="vertical">

        <ImageView
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:src="@drawable/select_course" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:text="SELECT A COURSE"
            android:textColor="#ffffff"
            android:textSize="25dp"
            android:textStyle="bold" />
    </LinearLayout>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="OK" />


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/dialogImageView"
        android:orientation="vertical"
        android:weightSum="2">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerViewSelectCourse"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:padding="5dp" />


        <android.support.v7.widget.CardView
            android:id="@+id/cardViewDemo1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:elevation="3dp"
            app:cardCornerRadius="10dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#e4a455"
                android:orientation="vertical"
                android:padding="10dp"
                android:weightSum="3">

                <android.support.v7.widget.CardView
                    android:id="@+id/cardViewDemo2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    app:cardCornerRadius="10dp">

                    <ImageView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:scaleType="fitXY"
                        android:src="@drawable/demo_one" />

                </android.support.v7.widget.CardView>

                <android.support.v7.widget.CardView
                    android:id="@+id/cardViewDemo3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_below="@id/cardViewDemo2"
                    android:layout_marginTop="5dp"
                    android:layout_weight="2"
                    app:cardCornerRadius="10dp">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#e9cca8">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerInParent="true"
                            android:text="DEMOVIDEOONE"
                            android:textColor="#fff"
                            android:textSize="15sp"
                            android:textStyle="bold" />

                    </RelativeLayout>
                </android.support.v7.widget.CardView>
            </LinearLayout>


        </android.support.v7.widget.CardView>

    </LinearLayout>

</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:crad_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
tools:context="com.software_solutions.optimus_tech_project201709.CourseSelect.CourseSelectionActivity">

<Button
    android:id="@+id/register"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:text="Register" />


<Button
    android:id="@+id/you"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:text="you" />

<ImageView
    android:id="@+id/dialogImageView"
    android:layout_width="match_parent"
    android:layout_height="220dp"
    android:scaleType="fitXY"
    android:src="@drawable/dialog"
    android:text="Hello" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/dialogImageView"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="-180dp"
    android:gravity="center"
    android:orientation="vertical">

    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@drawable/select_course" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="SELECT A COURSE"
        android:textColor="#ffffff"
        android:textSize="25dp"
        android:textStyle="bold" />
</LinearLayout>

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="OK" />


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/dialogImageView"
    android:orientation="vertical"
    android:weightSum="2">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerViewSelectCourse"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:padding="5dp" />


    <android.support.v7.widget.CardView
        android:id="@+id/cardViewDemo1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:layout_weight="1"
        android:elevation="3dp"
        card_view:cardCornerRadius="0dp"
        card_view:cardElevation="3dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#e4a455"
            android:orientation="vertical"
            android:padding="10dp"
            android:weightSum="3">

            <android.support.v7.widget.CardView
                android:id="@+id/cardViewDemo2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                card_view:cardCornerRadius="4dp"
                card_view:cardElevation="0dp">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    android:src="@drawable/demo_one" />

            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:id="@+id/cardViewDemo3"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/cardViewDemo2"
                android:layout_marginTop="5dp"
                android:layout_weight="2"
                app:cardCornerRadius="10dp">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#e9cca8">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true"
                        android:text="DEMOVIDEOONE"
                        android:textColor="#fff"
                        android:textSize="15sp"
                        android:textStyle="bold" />

                </RelativeLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>


    </android.support.v7.widget.CardView>

</LinearLayout>

添加 app:cardBackgroundColor="#e9cca8" app:cardBackgroundColor="#e4a455" 并移除子 RelativeLayout 和 LinearLayout 的背景

你有 3 个 CardView,在第 3 个 CardView 中,你只有 ImageView,所以最好不要使用 CardView,你可以使用圆角图像视图。