2016-07-31 100 views
0

下午好邊,兩個CardViews並排

什麼是側放兩個CardViews側(在同一行)的最佳方式,與他們兩個之間的距離呢?

感謝您的幫助!

+0

嘿@D。數學,下面的答案有幫助嗎? – Lino

+0

是的,它幫了很多,謝謝! –

回答

4

可以使用的LinearLayout與水平方向:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:weightSum="2" > 

    <android.support.v7.widget.CardView 
     android:id="@+id/card_viewLeft" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginRight="5dp" 
     android:layout_weight="1" /> 

    <android.support.v7.widget.CardView 
     android:id="@+id/card_viewRight" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginLeft="5dp" 
     android:layout_weight="1" /> 

</LinearLayout> 
+0

這兩者之間的差距呢? –

+0

good catch @ cricket_007,佈局已更新 – Lino

+1

雙邊距是一種方法..另一種是在兩個之間設置寬度的空''。 –