簡體   English   中英

海拔高度重疊的另一個CardView上方的CardView

[英]CardView above another CardView with elevation overlapping

是否可以使用cardview高程在布局下方歸檔。 在此處輸入圖片說明

由於我嘗試過很少的解決方案來存檔相同的文件,但到目前為止沒有成功。

1>解決方案1:

<RelativeLayout>
<AccountCardView>
<ChangePasswordCardView>
<EmailCardView>

作為相對布局,最后的大部分組件是最重要的,但這沒有用。

2>解決方案2:

我試圖給負的余量給cardview下面它顯示一些類似於上面的屏幕,僅在android studio布局編輯器中,當我嘗試將其安裝在真實設備或模擬器布局上時看起來像下面的樣子。 在此處輸入圖片說明

正如您只詢問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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM