![](/img/trans.png)
[英]How to stop cardview overlapping on android lollipop and above
[英]CardView above another CardView with elevation overlapping
正如您只詢問CardView一樣,這里有一個hack,這不是正確的方法。 如果您可以考慮采用其他方法來實現此布局,則建議您在每個分段(問題中的CardView)下方使用帶有陰影的額外視圖 。
請嘗試以下操作以使用CardView達到相同的目的
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto">
<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:layout_width="match_parent"
android:id="@+id/card_1"
android:layout_height="100dp"
card_view:cardElevation="15dp"
card_view:cardPreventCornerOverlap="false"/>
<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:layout_width="match_parent"
android:id="@+id/card_2"
android:layout_height="100dp"
card_view:cardElevation="14dp"
android:layout_below="@+id/card_1"
card_view:cardPreventCornerOverlap="false"/>
<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:layout_width="match_parent"
android:id="@+id/card_3"
android:layout_height="100dp"
card_view:cardElevation="13dp"
android:layout_below="@+id/card_2"
card_view:cardPreventCornerOverlap="false"/>
這將產生以下結果
此解決方案的問題是,如果您仔細注意,每張卡的仰角都小於前一張。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.