Java 带有cardview的Imageview未变圆

Java 带有cardview的Imageview未变圆,java,android,xml,Java,Android,Xml,您好,我正在制作一个应用程序,其中我正在尝试使用圆角的imageview制作cardview,但是当我运行该应用程序时,圆角没有显示出来,我不知道到底是什么问题。 我也尝试过使用自定义imageview,但当我起诉自定义imageview时,imageview获得了角半径,但黑角显示在卡上,并尝试在每个api级别上检查它,如android 5-8。 请检查我的xml <?xml version="1.0" encoding="utf-8"?> <android.support.

您好,我正在制作一个应用程序,其中我正在尝试使用圆角的imageview制作cardview,但是当我运行该应用程序时,圆角没有显示出来,我不知道到底是什么问题。 我也尝试过使用自定义imageview,但当我起诉自定义imageview时,imageview获得了角半径,但黑角显示在卡上,并尝试在每个api级别上检查它,如android 5-8。 请检查我的xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/primary_card"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="19dp"
    android:layout_marginRight="19dp"
    android:layout_marginTop="15dp"
    app:cardCornerRadius="35dp"
    app:contentPadding="0dp"
    app:cardPreventCornerOverlap="false"

    >

    <ImageView
        android:id="@+id/background_image_layout"
        android:layout_width="match_parent"
        android:layout_height="210dp"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        android:src="@drawable/club1" />

    <LinearLayout
        android:id="@+id/background_image"
        android:layout_width="match_parent"
        android:layout_height="210dp"
        android:orientation="vertical"
        >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/profile_image"
                android:layout_width="56dp"
                android:layout_height="56dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="20dp"
                android:src="@drawable/ellipse" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">


                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:padding="5dp">

                    <com.ct.listrtrial.Custom.CustomTextViewMedium
                        android:id="@+id/first_text"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="18dp"
                        android:padding="5dp"
                        android:text="John Doe"
                        android:textColor="@color/White"
                        android:textSize="15sp"
                       />

                    <com.ct.listrtrial.Custom.CustomTextViewMedium
                        android:id="@+id/second_text"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="18dp"
                        android:padding="5dp"
                        android:text="checked in to"
                        android:textColor="@color/White"
                        android:textSize="10sp" />

                    <com.ct.listrtrial.Custom.CustomTextViewMedium
                        android:id="@+id/third_text"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="18dp"
                        android:padding="5dp"
                        android:text="W south"
                        android:textColor="@color/White"
                        android:textSize="15sp" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:orientation="horizontal">

                    <com.ct.listrtrial.Custom.CustomTextViewMedium
                        android:id="@+id/fourth_text"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="9dp"
                        android:text="beach mumbai"
                        android:textColor="@color/White"
                        android:textSize="15sp" />

                    <com.ct.listrtrial.Custom.CustomTextViewMedium
                        android:id="@+id/fifth_text"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/second_text"
                        android:layout_toRightOf="@+id/fourth_text"
                        android:text="30 mins ago."
                        android:textColor="@color/White"
                        android:textSize="10sp" />
                </LinearLayout>
            </LinearLayout>


        </LinearLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="85dp">

            <com.ct.listrtrial.Custom.CustomTextViewMedium
                android:id="@+id/sixth_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerInParent="true"
                android:padding="10dp"
                android:text="reply to abc............"
                android:textColor="@color/White" />


            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerInParent="true">

                <ImageView
                    android:id="@+id/favourite_image"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="5dp"
                    android:adjustViewBounds="true"
                    android:scaleType="fitXY"
                    android:src="@drawable/ic_favorite_border_black_24dp" />

                <com.ct.listrtrial.Custom.CustomTextViewMedium
                    android:id="@+id/seventh_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="15dp"
                    android:text="40 likes"
                    android:textColor="@color/White" />
            </LinearLayout>
        </RelativeLayout>

    </LinearLayout>
</android.support.v7.widget.CardView>
见此——

layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/reviewLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.CardView
            android:id="@+id/card_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="19dp"
            android:layout_marginRight="19dp"
            android:layout_marginTop="15dp"
            app:cardCornerRadius="35dp"
            app:contentPadding="0dp"
            app:cardPreventCornerOverlap="false">

            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/imgProfile"
                android:layout_width="120dp"
                android:layout_height="120dp"
                android:layout_gravity="center"
                android:layout_marginRight="100dp"
                android:paddingBottom="10dp"
                android:paddingTop="10dp"
                android:src="@drawable/profile" />

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

                </LinearLayout>

</LinearLayout>


包括当前结果和预期结果,如果可能的话。我检查了你的xml,并尝试运行它。它工作正常。@史密斯,你能发布你当前的和预期的结果吗?你好,dhanshree,我不想使用circle imageview,因为我在cardview中的imageview没有占据拐角半径。她问到了cardview在图像上的半径效应。他在cardview中使用的图像。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/reviewLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.CardView
            android:id="@+id/card_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="19dp"
            android:layout_marginRight="19dp"
            android:layout_marginTop="15dp"
            app:cardCornerRadius="35dp"
            app:contentPadding="0dp"
            app:cardPreventCornerOverlap="false">

            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/imgProfile"
                android:layout_width="120dp"
                android:layout_height="120dp"
                android:layout_gravity="center"
                android:layout_marginRight="100dp"
                android:paddingBottom="10dp"
                android:paddingTop="10dp"
                android:src="@drawable/profile" />

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

                </LinearLayout>

</LinearLayout>