Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 阴影不显示在CardView中_Java_Android_Xml_Android Cardview - Fatal编程技术网

Java 阴影不显示在CardView中

Java 阴影不显示在CardView中,java,android,xml,android-cardview,Java,Android,Xml,Android Cardview,我正在开发一个android应用程序,其中我使用了cardview作为GridView的网格项 如果我同时使用cardwiew的背景图像,则在显示cardwiew的阴影时会遇到问题 代码片段: grid\u item.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/and

我正在开发一个android应用程序,其中我使用了
cardview
作为
GridView
的网格项

如果我同时使用
cardwiew
的背景图像,则在显示
cardwiew
的阴影时会遇到问题

代码片段

grid\u item.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_view"
    android:layout_width="@dimen/grid_item_width"
    android:layout_height="@dimen/grid_item_height"
    card_view:cardBackgroundColor="#80000000"
    card_view:cardElevation="2dp"
    card_view:cardUseCompatPadding="true">


    <LinearLayout
        android:id="@+id/profile_picture"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="@drawable/sample_expert_prof_pic"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:background="#8525272a"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:maxLines="1"
                    android:paddingLeft="@dimen/activity_horizontal_margin"
                    android:text="Shankar Venkat"
                    android:textColor="@color/white"

                    android:textSize="@dimen/grid_name_size" />

                <TextView
                    android:id="@+id/tags"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:maxLines="1"
                    android:paddingBottom="2dp"
                    android:paddingLeft="@dimen/activity_horizontal_margin"
                    android:paddingTop="5dp"
                    android:text="#finance# accounts"
                    android:textColor="@color/white"
                    android:textSize="@dimen/grid_tags_size" />
            </LinearLayout>

        </RelativeLayout>

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


请任何人帮我找到解决方案。

也许你真正的设备是棒棒糖设备


尝试将card\u view:cardUseCompatding=“true”添加到xml中,阴影将出现。

使用属性app:elevation=“4dp”而不是card\u view:cardElevation=“2dp”使用安卓:elevation=“4dp”。我已经尝试了app:elevation=“4dp”和安卓:elevation=“4dp”。但不工作:-(您正在使用哪个设备?在棉花糖上运行的Mi 4我的设备正在使用棉花糖运行。我已尝试使用card\u view:cardUseCompatPadding=“true”但不工作:-(