2017-09-17 56 views
0

是否可以使用cardview海拔在佈局下進行歸檔? enter image description hereCardView在海拔重疊的另一個CardView上方

正如我已經嘗試過幾個解決方案來歸檔相同但沒有成功截至目前。

1>解決方案1:

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

爲相對佈局最後大部分組件出現在所有但上面沒有工作。

2>解決方案2:

我試圖否定的利潤率低於cardview它表現出一定的,當我試圖在實際設備或模擬器的佈局似乎安裝它什麼類似上面的屏幕僅在Android Studio中佈局編輯器,看起來像一個下面。 enter image description here

回答

1

由於您只詢問CardView,因此存在黑客攻擊,這不是正確的做法。如果您可以選擇考慮其他方式來實現此佈局,我會建議使用具有額外的視圖與下面的每個段(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"/> 

這將產生附加以下

enter image description here

的問題與此解決方案的結果是,如果你發現仔細地說,每張牌的高度都比前一張低。

+0

這看起來非常類似於我所要求的感謝此解決方法。我也會嘗試在每張卡片視圖下面繪製解決方案。非常感謝.. –

+0

歡迎您:) – Aveek