根据我的理解,在预览阶段的早期,似乎没有办法只在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
我在我的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
android ×2