购物车1

来源:互联网 发布:mac 东芝移动硬盘 编辑:程序博客网 时间:2024/06/05 07:26
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.dash.a18_shopping_cart.view.MainActivity">


    <ScrollView
        android:layout_above="@+id/linear_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

            <!--购物车的二级列表-->
            <com.dash.a18_shopping_cart.view.custom.CartExpanableListview
                android:id="@+id/expanable_listview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

            </com.dash.a18_shopping_cart.view.custom.CartExpanableListview>

            <!--为你推荐-->
            <LinearLayout
                android:layout_marginTop="20dp"
                android:orientation="vertical"
                android:background="#00ff00"
                android:layout_width="match_parent"
                android:layout_height="500dp">

            </LinearLayout>



        </LinearLayout>


    </ScrollView>

    <LinearLayout
        android:id="@+id/linear_layout"
        android:layout_alignParentBottom="true"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="50dp">
        <CheckBox
            android:layout_marginLeft="10dp"
            android:button="@null"
            android:background="@drawable/check_box_selector"
            android:id="@+id/check_all"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/text_total"
            android:text="合计:¥0.00"
            android:layout_weight="2"
            android:layout_width="0dp"
            android:layout_height="wrap_content" />

        <TextView
            android:text="去结算(0)"
            android:background="#ff0000"
            android:textColor="#ffffff"
            android:gravity="center"
            android:id="@+id/text_buy"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent" />

    </LinearLayout>

</RelativeLayout>


//需要重写二级列表

public class CartExpanableListview extends ExpandableListView {
    public CartExpanableListview(Context context) {
        super(context);
    }

    public CartExpanableListview(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CartExpanableListview(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int height = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE>>2,MeasureSpec.AT_MOST);

        super.onMeasure(widthMeasureSpec, height);
    }


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="10dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <CheckBox
        android:layout_centerVertical="true"
        android:id="@+id/check_child"
        android:button="@null"
        android:background="@drawable/check_box_selector"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <ImageView
        android:id="@+id/image_good"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/check_child"
        android:layout_marginLeft="10dp"
        android:layout_width="80dp"
        android:layout_height="80dp" />

    <TextView
        android:id="@+id/text_title"
        android:layout_toRightOf="@+id/image_good"
        android:layout_marginLeft="10dp"
        android:layout_alignTop="@+id/image_good"
        android:maxLines="2"
        android:minLines="2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/text_price"
        android:layout_toRightOf="@+id/image_good"
        android:layout_marginLeft="10dp"
        android:layout_alignBottom="@+id/image_good"
        android:text="¥99.99"
        android:textColor="#ff0000"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <LinearLayout
        android:layout_alignParentRight="true"
        android:layout_alignBottom="@+id/image_good"
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/text_jian"
            android:text="一"
            android:padding="5dp"
            android:background="@drawable/bian_kuang_line"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:gravity="center"
            android:id="@+id/text_num"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:background="@drawable/bian_kuang_line"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />

        <TextView
            android:id="@+id/text_add"
            android:text="十"
            android:padding="5dp"
            android:background="@drawable/bian_kuang_line"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>


</RelativeLayout>


原创粉丝点击