0

i need help. i have a RecyclerView containing different View such as Cardviews. Those CardViews contains a ListView

the cardViews height is wrap content and the listviews hight is also wrap content.

the listView in the first card contains three items the second card only one and the last card has a subitem.

how can i archive that the cards grow if their content change or if the expandableListView opens

i'm sorry for my bad engish

Screenshot of view enter image description here

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.v7.widget.CardView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/card_vocdetail_general"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:orientation="vertical">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <ExpandableListView
            android:id="@+id/card_vocdetail_expandableList"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:minHeight="48dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <LinearLayout
            android:id="@+id/card_vocdetail_more"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"

    app:layout_constraintTop_toBottomOf="@+id/card_vocdetail_expandableList">

            <TextView
                android:id="@+id/card_vocdetail_more_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/card_detail_voc_more_sides"
                app:layout_constraintStart_toStartOf="parent"

    app:layout_constraintTop_toBottomOf="@+id/card_vocdetail_expandableList" />

            <TextView
                android:id="@+id/textView28"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:clickable="true"
                android:gravity="end"
                android:text="@string/show_more" />
        </LinearLayout>

    </LinearLayout>

</android.support.v7.widget.CardView>
Mr. Roshan
  • 1,777
  • 13
  • 33
anika
  • 153
  • 1
  • 2
  • 6
  • 1
    What you want exactly? – Ankita Jul 06 '18 at 07:15
  • As an option you can check this post for ListView: https://stackoverflow.com/questions/11295080/android-wrap-content-is-not-working-with-listview – redlabrat Jul 06 '18 at 08:05
  • Try calculate the height of ExpandableListView on runtime. Do something similar to this answer: https://stackoverflow.com/questions/50945605/the-expandablelistview-adapter-child-not-updated-on-runtime-by-calling-notifydat Hope that helps! – i_A_mok Jul 09 '18 at 02:49

0 Answers0