Listview中的我的Cardview没有在Android L(Nexus 5)中显示阴影.圆形边缘也未正确显示.以下是Listview的适配器视图的代码:
<?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"
xmlns:app="http://schemas.android.com/apk/res/com.example.myapp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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"
app:cardBackgroundColor="@android:color/white"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="4dp"
app:cardElevation="4dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="@dimen/padding_small"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/ivPicture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvName"
android:layout_centerHorizontal="true"
android:scaleType="fitCenter" />
<TextView
android:id="@+id/tvDetail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ivPicture"
android:layout_centerHorizontal="true"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" />
</RelativeLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
和ListView xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res/com.example.myapp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/app_bg" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:cacheColorHint="#00000000"
android:divider="@android:color/transparent"
android:drawSelectorOnTop="true"
android:smoothScrollbar="true" /> …Run Code Online (Sandbox Code Playgroud) android android-listview material-design android-cardview android-5.0-lollipop
Google是否已经为这个新的循环FAB按钮发布了已定义的样式或组件,还是应该自行实现该设计?
按钮在此处描述:Google Design | 浮动动作按钮
编辑(05/2015):检查Lukas的回答/Gabriele的答案显示了使用设计支持库实现它的简单方法.
java android material-design android-5.0-lollipop android-design-library
我有以下xml的cardview:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" android:padding="2dp">
<!-- A CardView that contains a TextView -->
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="wrap_content"
card_view:cardCornerRadius="0dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<TextView
android:id="@+id/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这导致这些阴影底部没有阴影

但我试图得到像这样的影子,更好地围绕整个卡片.

我试着改变海拔无济于事,和搜索在这个问题上,似乎带来了什么,但人们没有阴影,在所有这不是我的情况的问题.
我怎样才能让阴影正确?
谢谢.
应用Proguard后,我的CardView阴影在Lollipop设备上消失了.我没有定义任何保护这个库的规则,因为我没有阅读它是必要的.
我附上了几个屏幕截图,首先是没有运行proguard,然后是运行后的secon.
这是我的xml
<LinearLayout 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"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="4dp"
app:contentPadding="10dp"
app:cardUseCompatPadding="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text 1"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="4dp"
app:contentPadding="10dp"
app:cardUseCompatPadding="false">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text 2"/>
</android.support.v7.widget.CardView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Activity仅将xml设置为内容,不再执行任何操作.正如您所看到的,我正在使用两种可能性cardUseCompatPadding,但它并没有解决问题,因为它在此线程中定义.
有谁知道为什么proguard打破我的阴影?
我在CardView中有一个RelativeLayout,我想在Android Lollipop中提升但是没有显示高程(阴影没有显示):

我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android.support.v7.cardview="http://schemas.android.com/apk/res-auto"
style="@style/CardViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="5dp"
android:orientation="horizontal"
android.support.v7.cardview:cardElevation="5dp">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_selector"
android:paddingBottom="5dp">
<ImageView
android:id="@+id/article_thumb"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_alignParentTop="true"
android:contentDescription="@string/app_name"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/article_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/article_thumb"
android:layout_marginEnd="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:ellipsize="middle"
android:linksClickable="false"
android:longClickable="false"
android:text="@string/title"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:textColor="@color/black" />
<TextView
android:id="@+id/article_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/article_title"
android:layout_alignStart="@+id/article_title"
android:layout_below="@+id/article_title"
android:layout_marginTop="10dp"
android:text="@string/date"
android:textAppearance="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Small"
android:textColor="@color/gray" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/article_title"
android:layout_alignRight="@+id/article_title"
android:layout_below="@+id/article_title"
android:layout_marginTop="10dp"
android:elevation="30dp"
android:translationZ="30dp">
<ImageView
android:id="@+id/redbubble"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:contentDescription="@string/app_name"
android:scaleType="centerCrop"
android:src="@drawable/redbubble" />
<TextView
android:id="@+id/article_comment_bubble"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" …Run Code Online (Sandbox Code Playgroud) android material-design android-cardview android-5.0-lollipop android-elevation