如何停止 android 棒棒糖及以上的 cardview 重叠
How to stop cardview overlapping on android lollipop and above
我制作了一个应用程序以在回收站视图中从 json 读取数据。当我 运行 android 4.4 上的应用程序看起来像这样 IMAGE but when i run it on an android 5.0 or above it looks like this IMAGE
这是卡片视图布局的代码
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="80dp"
xmlns:app="http://schemas.android.com/tools"
app:cardElevation="5dp"
app:cardCornerRadius="0.5dp"
app:cardUseCompatPadding="true"
android:layout_margin="1dp">
<RelativeLayout
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="80dp">
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_alignParentRight="true"
android:text="123"
android:textColor="#565656"
android:textSize="9dp" />
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:id="@+id/comment"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@+id/thumbnail" />
<TextView
android:layout_width="12dp"
android:layout_height="12dp"
android:textColor="#000000"
android:id="@+id/textView"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@+id/comment" />
<TextView
android:layout_width="match_parent"
android:layout_height="15dp"
android:textColor="#3f51b4"
android:text="NEWS"
android:textSize="8dp"
android:id="@+id/categories"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/textView" />
<ImageView
android:id="@+id/thumbnail"
android:layout_width="80dp"
android:layout_height="69dp"
android:scaleType="centerCrop"
android:background="#919191"
android:layout_marginStart="6dp"
android:layout_centerVertical="true"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="3"
android:padding="8dp"
android:text="MMM is now back in buisness so if your money dy dia better go collect am no"
android:textStyle="bold"
android:textColor="#222"
android:textSize="12dp"
android:layout_alignTop="@+id/thumbnail"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@+id/thumbnail" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/excerpt"
android:maxLines="3"
android:textSize="7dp"
android:text="if your money dy dia go collect am nw o"
android:layout_below="@+id/title"
android:layout_toEndOf="@+id/comment" />
</RelativeLayout>
</android.support.v7.widget.CardView>
有什么帮助吗?
尝试更改您的应用名称space 声明来自:
xmlns:app="http://schemas.android.com/tools"
至:
xmlns:app="http://schemas.android.com/apk/res-auto"
看看会有什么帮助,因为您已经在使用 app:cardUseCompatPadding="true"
在 android 5.0 中,这应该使 space 介于卡片之间。同时添加 app:cardPreventCornerOverlap="false"
我制作了一个应用程序以在回收站视图中从 json 读取数据。当我 运行 android 4.4 上的应用程序看起来像这样 IMAGE but when i run it on an android 5.0 or above it looks like this IMAGE
这是卡片视图布局的代码
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="80dp"
xmlns:app="http://schemas.android.com/tools"
app:cardElevation="5dp"
app:cardCornerRadius="0.5dp"
app:cardUseCompatPadding="true"
android:layout_margin="1dp">
<RelativeLayout
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="80dp">
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_alignParentRight="true"
android:text="123"
android:textColor="#565656"
android:textSize="9dp" />
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:id="@+id/comment"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@+id/thumbnail" />
<TextView
android:layout_width="12dp"
android:layout_height="12dp"
android:textColor="#000000"
android:id="@+id/textView"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@+id/comment" />
<TextView
android:layout_width="match_parent"
android:layout_height="15dp"
android:textColor="#3f51b4"
android:text="NEWS"
android:textSize="8dp"
android:id="@+id/categories"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/textView" />
<ImageView
android:id="@+id/thumbnail"
android:layout_width="80dp"
android:layout_height="69dp"
android:scaleType="centerCrop"
android:background="#919191"
android:layout_marginStart="6dp"
android:layout_centerVertical="true"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="3"
android:padding="8dp"
android:text="MMM is now back in buisness so if your money dy dia better go collect am no"
android:textStyle="bold"
android:textColor="#222"
android:textSize="12dp"
android:layout_alignTop="@+id/thumbnail"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@+id/thumbnail" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/excerpt"
android:maxLines="3"
android:textSize="7dp"
android:text="if your money dy dia go collect am nw o"
android:layout_below="@+id/title"
android:layout_toEndOf="@+id/comment" />
</RelativeLayout>
</android.support.v7.widget.CardView>
有什么帮助吗?
尝试更改您的应用名称space 声明来自:
xmlns:app="http://schemas.android.com/tools"
至:
xmlns:app="http://schemas.android.com/apk/res-auto"
看看会有什么帮助,因为您已经在使用 app:cardUseCompatPadding="true"
在 android 5.0 中,这应该使 space 介于卡片之间。同时添加 app:cardPreventCornerOverlap="false"