【问题标题】:How to make a grid layout of CardViews with variable height? [duplicate]如何制作具有可变高度的 CardViews 的网格布局? [复制]
【发布时间】:2015-09-30 00:56:57
【问题描述】:

我在 XML 中定义了多个 CardView

<android.support.v7.widget.CardView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    card_view:cardPreventCornerOverlap="false"
    card_view:cardCornerRadius="4dp">
    <LinearLayout
        android:layout_width="wrap_content"
        android:orientation="vertical"
        android:layout_height="wrap_content">
        <TextView
            android:textSize="@dimen/abc_text_size_title_material"
            android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</android.support.v7.widget.CardView>

对于手机,我将多个CardView 包装在一个垂直的LinearLayout 中:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

对于平板电脑,我想改用网格布局,类似于Material Design specs 中使用的设计,参见图片here

最适合用来制作网格布局的ViewGroup 是什么?卡片高度可变,内容静态。

GridLayout 无法使用,因为卡片高度可变。

【问题讨论】:

    标签: android android-layout material-design


    【解决方案1】:

    对于平板电脑,您可以使用 2 个线性布局。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-22
      • 1970-01-01
      • 2021-12-20
      • 1970-01-01
      • 1970-01-01
      • 2012-01-17
      • 1970-01-01
      • 2018-03-30
      相关资源
      最近更新 更多