从gmariotti cards lib更改布局大小

时间:2015-01-27 15:01:10

标签: android

我试图在我的活动中设置较小的卡片大小,但不确定如何引用它(卡片: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>

1 个答案:

答案 0 :(得分:0)

默认卡片具有最小高度,如documentation中所述。

因此您需要添加:

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

style name="card.content_outer_layout"

此方法以设置所有卡片的minHeight结束。但是,如果要为特定卡片设置高度,可以先构建自定义卡片布局,然后在android:adjustViewBounds="true"中设置ImageView。有关更多详细信息和其他解决方案,请参阅this question