简体   繁体   English

在Android的cardListView中扩展卡内

[英]Expand inside card in cardListView in android

I am using cardslib to show expandable list of cards in cardListview, so the problem is when I tap on card it expands always at the bottom of the card but I want the card should expand inside my custom card layout(as shown in layout_home_item.xml). 我正在使用cardslib在cardListview中显示可扩展的卡片列表,所以问题是当我点击card时,卡片总是在卡片的底部扩展,但是我希望卡片应该在我的自定义卡片布局内扩展(如layout_home_item.xml中所示) )。

I have referred cardslib documentation but couldn't able to figure it out. 我已经参考了cardslib文档,但无法弄清楚。 below is the code suggested by @gabrielemariotti : to use 以下是@gabrielemariotti建议的代码:

card:card_layout_resourceID="@layout/layout_home_item" 卡: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 : 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" />

You didn't post any actual code that shows how you create Card so it's hard to understand what you are doing. 您没有发布任何实际的代码来显示Card的创建方式,因此很难理解您在做什么。

Expand Card Inside or Outside is a new Card that you have to create and attach to your existing card. 在内部或外部扩展卡是您必须创建并附加到现有卡上的新卡。 You can not achieve by just changing your layout of existing Card. 您不能仅通过更改现有卡的布局来实现。

Here's how you can attach Inside Card to a Card. 这是将“内部卡”附加到卡上的方法。

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

You can see the example here https://github.com/gabrielemariotti/cardslib/blob/master/demo/stock/src/main/java/it/gmariotti/cardslib/demo/fragment/nativeview/NativeCardExpandFragment.java Look for this function in the file 您可以在这里查看示例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