Java cardview未显示拐角半径和标高

Java cardview未显示拐角半径和标高,java,android,kotlin,Java,Android,Kotlin,我在recycler视图中创建了一个card视图,我的代码工作得很好,但现在的问题是cardview在运行时不显示圆角和高程,而是显示在设计代码中。我的代码显示为blow 主要活动 <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-au

我在recycler视图中创建了一个card视图,我的代码工作得很好,但现在的问题是cardview在运行时不显示圆角和高程,而是显示在设计代码中。我的代码显示为blow

主要活动

<android.support.constraint.ConstraintLayout 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"
    tools:context=".Controller.MainActivity">

    <uk.co.markormesher.android_fab.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:buttonIcon="@drawable/ic_add_group"
        />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/groupListView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

mycard_view.xml

<android.support.constraint.ConstraintLayout 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="wrap_content">

<android.support.v7.widget.CardView
    android:id="@+id/groupCardView"
    android:layout_width="match_parent"
    android:layout_height="128dp"
    android:layout_marginEnd="16dp"
    android:layout_marginStart="16dp"
    android:layout_marginTop="24dp"
    app:cardCornerRadius="10dp"
    app:cardElevation="5dp"
    app:cardUseCompatPadding="true"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent">

        <TextView
            android:id="@+id/groupTitle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:text="Trips"
            android:textAlignment="center"
            android:textSize="30sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>


我不知道我做错了什么

任何人都可能遇到这个问题,解决方法非常简单,而且是由错误引起的。
backgroundColor
cardbackgroundColor
之间有区别。使用setcardbackgroundColor,它应该可以工作。

您需要设置

android:background="@android:color/transparent"
用于主约束,并设置

app:cardBackgroundColor="@color/white"

对于cardview,np

将背景色设置为cardview。您设置的颜色与页面使用的颜色相同。我发现了错误。我设置的是背景色而不是cardbackgroundcolor