2017-09-17 11 views
0

cardview高度を使用して、以下のレイアウトをアーカイブすることは可能ですか? enter image description here隆起が重なる別のCardView上のCardView

私は今までと同じだが成功しなかったいくつかのソリューションを試しました。

1>解決方法1:相対的なレイアウトとして

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

最後のほとんどのコンポーネントは、それが動作しませんでしたが、すべての上に来ます。

2>解決策2:

私が試した実際のデバイスまたはエミュレーターレイアウトへのインストール私が試したとき、それは、唯一のAndroidスタジオレイアウトエディタで上記の画面に似たいくつかの何を示してcardview以下に負のマージンを与えてはいるようです下のように見える。 enter image description here

答えて

1

CardViewについてのみ聞いたことがあるので、ハックがあり、正しい方法ではありません。このレイアウトを達成するために他の方法を検討することができれば、余分なを使用することをお勧めします。各セグメント(問題のCardView)の下にドロップシャドウがあります。

これは、あなたが気づいた場合、この解決策で問題がある

enter image description here

の下に取り付けた結果を生成します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"/> 

と同じことを達成するために、以下のようにしてみてください注意深く、各カードは前のものよりも低い標高を有する。

+0

これは私がこの回避策に感謝の意を込めて尋ねたものと非常によく似ています。私はまた、各カードビューの下に描画可能なソリューションを試してみます。ありがとうございます.. –

+0

あなたは大歓迎です:) – Aveek