相关疑难解决方法(0)

在Android 5.0上的AppCompat CardView上设置XML高程

根据我的理解,在预览阶段的早期,似乎没有办法只在CardView没有Java的黑客攻击的情况下在XML中设置高程.既然官方发布已经发布,有没有办法在XML中执行此操作而无需编写Java代码来设置高程?

我试过card_view:cardElevation没有效果.我曾经想过当我使用5.0的模拟器时一切都很好.但是现在我在我的实际设备上使用正式版本,我的所有内容都CardView消失了

Pre Lollipop,效果很好.

这是我的完整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:orientation="horizontal"
    android:layout_width="match_parent"
    android:id="@+id/cv1"
    card_view:cardElevation="4dp"
    android:layout_margin="6dp"
    card_view:cardCornerRadius="3dp"
    android:layout_height="match_parent">
Run Code Online (Sandbox Code Playgroud)

android android-appcompat android-cardview android-elevation

92
推荐指数
3
解决办法
8万
查看次数

Cardview阴影没有出现在棒棒糖设备中?

我在我的Android应用程序中使用cardview.然而阴影没有显示出来.这是xml布局

默认选项菜单阴影也未显示.

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

    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:clipChildren="false"
        card_view:cardBackgroundColor="@color/white"
        card_view:cardCornerRadius="4dp"
        card_view:cardElevation="14dp"
        card_view:cardUseCompatPadding="true" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="20dp"
            android:text="Google Play" />
    </android.support.v7.widget.CardView>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

请参阅附件

android android-layout android-cardview android-5.0-lollipop

32
推荐指数
3
解决办法
3万
查看次数