ExpandableListview将子项和组合并在同一cardview中

时间:2019-03-20 07:19:05

标签: android android-layout expandablelistview android-cardview

想使用附属的Expandablelistview在一个Cardview中实现子合并合并。不想使用可扩展的Cardview,因为我的全部功能都准备好了,这将花费我很多时间。建议我提供一个出路或一个可在短时间内实现的图书馆。

list_parent.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="@dimen/_5sdp"
        android:elevation="@dimen/_10sdp"
        card_view:cardCornerRadius="@dimen/_5sdp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="6.1">

            <ImageView
                android:id="@+id/actionIcon"
                android:layout_width="0dp"
                android:layout_height="@dimen/_30sdp"
                android:layout_gravity="center_vertical"
                android:layout_marginRight="@dimen/_5sdp"
                android:layout_weight=".5"
                android:tint="?attr/primaryColor"
                app:srcCompat="@drawable/ic_keyboard_arrow_down" />
        </LinearLayout>
    </android.support.v7.widget.CardView>
</LinearLayout>

list_child.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/border_primary_bottom"
        android:clickable="true"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/expandedListItem"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:clickable="true"
            android:gravity="center"
            android:padding="@dimen/_5sdp"
            android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"
            android:text="FSU1"
            android:textColor="?attr/fontColorPrimary" />

        <LinearLayout
            android:layout_width="@dimen/_180sdp"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/_4sdp"
                android:clickable="true"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/tv_percentage"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="@dimen/_2sdp"
                    android:layout_weight="1"
                    android:background="?attr/blueColor"
                    android:clickable="true"
                    android:gravity="center"
                    android:text="54%"
                    android:textColor="?attr/whiteColor" />

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="@dimen/_2sdp"
                    android:layout_weight="1"
                    android:background="@drawable/edittext_background"
                    android:gravity="center"
                    android:inputType="number"
                    android:maxLength="4"
                    android:padding="@dimen/_2sdp" />

                <EditText
                    android:id="@+id/et_itc_inds"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="@dimen/_2sdp"
                    android:layout_weight="1"
                    android:background="@drawable/edittext_background"
                    android:gravity="center"
                    android:inputType="number"
                    android:maxLength="4"
                    android:padding="@dimen/_2sdp" />
            </LinearLayout>

            <TextView
                android:id="@+id/tv_deficit_val"
                android:layout_width="match_parent"
                android:layout_height="@dimen/_25sdp"
                android:layout_margin="@dimen/_4sdp"
                android:layout_weight="1"
                android:background="?attr/greenColor"
                android:clickable="true"
                android:gravity="center"
                android:text=""
                android:textColor="?attr/whiteColor"
                android:visibility="gone" />

            <TextView
                android:id="@+id/tv_qualityof_facing"
                android:layout_width="match_parent"
                android:layout_height="@dimen/_25sdp"
                android:layout_margin="@dimen/_4sdp"
                android:layout_weight="1"
                android:background="?attr/blueColor"
                android:clickable="true"
                android:gravity="center"
                android:text="Quality of facing"
                android:textColor="?attr/whiteColor" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

group view and child merge in a single cardview

Now the list is coming like this

0 个答案:

没有答案