【问题标题】:Two CardViews side by side两个 CardView 并排
【发布时间】:2016-08-01 01:36:45
【问题描述】:

下午好,

将两个 CardView 并排放置(在同一行)的最佳方法是什么,它们之间有一个边距?

感谢您的帮助!

【问题讨论】:

  • 嘿@D。数学,下面的答案有帮助吗?
  • 是的,它帮了很多忙,谢谢!

标签: android xml margin android-cardview


【解决方案1】:

您可以使用具有水平方向的 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>

【讨论】:

  • 两者的margin怎么样?
  • 双边距是一种方式。另一种是在两者之间设置宽度的空&lt;View&gt;
猜你喜欢
  • 1970-01-01
  • 2018-01-08
  • 2012-09-08
  • 2013-01-13
  • 2017-03-26
  • 2013-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多