为什么棒棒糖上的CardViews之间没有空间? [英] Why there is no space between CardViews on Lollipop?
本文介绍了为什么棒棒糖上的CardViews之间没有空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用CardView
,它在5.0以下时仍能很好地工作,但在棒棒糖上看起来很奇怪.
I try to use the CardView
and it works well below 5.0, but looks strange on Lollipop.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<android.support.v7.widget.CardView android:layout_width="match_parent"
android:layout_height="200dp">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="card1"
android:textAppearance="?android:attr/textAppearanceLarge" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView android:layout_width="match_parent"
android:layout_height="200dp">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="card2"
android:textAppearance="?android:attr/textAppearanceLarge" />
</android.support.v7.widget.CardView>
</LinearLayout>
使用RecyclerView
时遇到相同的问题,如果它在Lollipop上运行,是否还需要添加一些内容?
I meet the same question when i use the RecyclerView
, should I have to add something if it runs on Lollipop?
推荐答案
在CardView
上设置:
app:cardUseCompatPadding="true"
摘自文档:
还要在API v21 +中添加填充,以便与 以前的版本.
Add padding in API v21+ as well to have the same measurements with previous versions.
这篇关于为什么棒棒糖上的CardViews之间没有空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文