两个 CardView 并排
Two CardViews side by side
下午好,
将两个 CardView 并排(在同一行)并在它们之间留出空白的最佳方法是什么?
感谢您的帮助!
您可以使用水平方向的 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>
下午好,
将两个 CardView 并排(在同一行)并在它们之间留出空白的最佳方法是什么?
感谢您的帮助!
您可以使用水平方向的 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>