【问题标题】:Expand inside card in cardListView in android在 android 的 cardListView 中展开卡片内部
【发布时间】:2015-04-18 09:02:55
【问题描述】:

我正在使用cardlib在cardListview中显示可扩展的卡片列表,所以问题是当我点击卡片时它总是在卡片底部展开,但我希望卡片应该在我的自定义卡片布局内展开(如图所示layout_home_item.xml)。

我参考了cardlib 文档,但无法弄清楚。 以下是@gabrielemariotti 建议的代码:使用

card:card_layout_resourceID="@layout/layout_home_item"

 <it.gmariotti.cardslib.library.view.CardListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="10dp"
    card:card_layout_resourceID="@layout/layout_home_item"
    android:id="@+id/list" />

layout_home_item.xml:

<?xml version="1.0" encoding="utf-8"?><!-- A CardView that contains a TextView --><!-- A CardView that contains a TextView -->

<TextView
    android:id="@+id/question_text"
    android:layout_below="@id/user_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_toLeftOf="@id/read_more_img"
    android:textSize="16sp"
    android:layout_marginTop="20dp"
    android:layout_marginLeft="20dp"
    android:layout_marginBottom="20dp"
    android:textColor="@color/black" />

**<FrameLayout                                 //inner expanded area
    android:id="@+id/card_content_expand_layout"
    style="@style/card.main_contentExpand"
    android:layout_marginBottom="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_below="@id/question_text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"></FrameLayout>**

<ImageView
    android:id="@+id/question_img"
    android:layout_below="@id/card_content_expand_layout"
    android:layout_width="match_parent"
    android:src="@drawable/mat2"
    android:layout_height="270dp" />

【问题讨论】:

    标签: android android-listview cardslib android-cards


    【解决方案1】:

    您没有发布任何显示您如何创建 Card 的实际代码,因此很难理解您在做什么。

    在内部或外部扩展卡是您必须创建并附加到现有卡的新卡。您无法仅通过更改现有卡片的布局来实现。

    下面介绍了如何将 Inside Card 附加到卡片上。

    Card card = new Card() // your actual Card
    CardExpandInside expand = new CardExpandInside(context);
    card.addCardExpand(expand);
    

    您可以在此处查看示例https://github.com/gabrielemariotti/cardslib/blob/master/demo/stock/src/main/java/it/gmariotti/cardslib/demo/fragment/nativeview/NativeCardExpandFragment.java 在文件中寻找这个函数

    init_custom_card_expand_inside()
    

    【讨论】:

      猜你喜欢
      • 2020-07-24
      • 2021-07-21
      • 1970-01-01
      • 2021-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-11
      • 2020-08-26
      相关资源
      最近更新 更多