【问题标题】:Changing size of layout from gmariotti cards lib从 gmariotti 卡片库更改布局大小
【发布时间】:2015-10-03 06:21:56
【问题描述】:

我正在尝试在我的活动中将卡片尺寸设置得更小,但不确定如何因为它是如何引用它的(card:card_layout_resourceID="@layout/card_thumbnail_layout")。

所以我的问题是如何使用这个库但改变下面卡片的高度?

这是一张卡片

    <it.gmariotti.cardslib.library.view.CardView
        android:id="@+id/carddemo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card:card_layout_resourceID="@layout/card_thumbnail_layout"
        android:layout_below="@+id/currentTerm"
        />

@layout/card_thumbnail_layout:(无法编辑,因为它在构建文件夹中)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:card="http://schemas.android.com/apk/res-auto"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content">

    <!-- Card visible layout -->
    <LinearLayout
        android:id="@+id/card_main_layout"
        style="@style/card.main_layout"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

        <!-- Compound view for Header Card
             If you want to customize this element use attr card:card_header_layout_resourceID
             You can also use your CardHeader subclass-->
        <it.gmariotti.cardslib.library.view.component.CardHeaderView
            style="@style/card.header_outer_layout"
            android:id="@+id/card_header_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <LinearLayout
            android:id="@+id/card_thumb_and_content_layout"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <it.gmariotti.cardslib.library.view.component.CardThumbnailView
                style="@style/card_thumbnail_outer_layout"
                android:id="@+id/card_thumbnail_layout"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"/>

            <!-- Main Content View -->
            <FrameLayout
                android:id="@+id/card_main_content_layout"
                style="@style/card.content_outer_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>

        </LinearLayout>

    </LinearLayout>

    <!-- Compound view for Shadow
         If you want to customize this element use attr card:card_shadow_layout_resourceID -->
    <it.gmariotti.cardslib.library.view.component.CardShadowView
        style="@style/card.shadow_outer_layout"
        android:id="@+id/card_shadow_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <!-- Expand layout. You can customize this element with your CardExpand class -->
    <FrameLayout
        android:id="@+id/card_content_expand_layout"
        style="@style/card.main_contentExpand"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
    </FrameLayout>

</LinearLayout>

【问题讨论】:

标签: android


【解决方案1】:

默认卡片有一个最小高度,在documentation 中指定。

因此需要添加:

<item name="android:minHeight">your_value_in_dp</item>

style name="card.content_outer_layout"

这种方法以设置所有卡片的minHeight 结束。但是,如果您想为特定卡片设置高度,您可以首先构建自定义卡片布局并在您的 ImageView 中设置 android:adjustViewBounds="true"。更多详情和其他解决方案,请参阅this question

【讨论】:

    猜你喜欢
    • 2016-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多