簡體   English   中英

在Android的cardListView中擴展卡內

[英]Expand inside card in cardListView in android

我正在使用cardslib在cardListview中顯示可擴展的卡片列表,所以問題是當我點擊card時,卡片總是在卡片的底部擴展,但是我希望卡片應該在我的自定義卡片布局內擴展(如layout_home_item.xml中所示) )。

我已經參考了cardslib文檔,但無法弄清楚。 以下是@gabrielemariotti建議的代碼:

卡: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" />

您沒有發布任何實際的代碼來顯示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()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM