购物车的布局

来源:互联网 发布:sci论文润色软件 编辑:程序博客网 时间:2024/06/04 19:32

购物车的主页面

<?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.example.lianxi.View.carActivity">     //二级列表    <com.example.lianxi.Utils.CartExpanableListview        android:id="@+id/expanable_listview"        android:layout_width="match_parent"        android:layout_height="wrap_content">   </com.example.lianxi.Utils.CartExpanableListview>    <RelativeLayout        android:visibility="visible"        android:id="@+id/relative_progress"        android:layout_above="@+id/linear_layout"        android:layout_width="match_parent"        android:layout_height="match_parent">        <ProgressBar            android:layout_centerInParent="true"            android:layout_width="wrap_content"            android:layout_height="wrap_content" />    </RelativeLayout>    <LinearLayout        android:background="#fff"        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>
一级标题 group_item_layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="horizontal"    android:gravity="center_vertical"    android:padding="10dp"    android:layout_width="match_parent"    android:layout_height="match_parent">    <CheckBox        android:button="@null"        android:background="@drawable/check_box_selector"        android:id="@+id/check_group"        android:layout_width="wrap_content"        android:layout_height="wrap_content" />    <TextView        android:layout_marginLeft="10dp"        android:text="京东自营"        android:id="@+id/text_group"        android:layout_width="wrap_content"        android:layout_height="wrap_content" /></LinearLayout>
二级列表标题 child_item_layout
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:padding="10dp"    android:layout_width="match_parent"    android:layout_height="match_parent">    <RelativeLayout        android:id="@+id/rel"        android:layout_toLeftOf="@+id/text_delete"        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>    <TextView        android:layout_marginLeft="3dp"        android:layout_alignParentRight="true"        android:layout_alignTop="@+id/rel"        android:layout_alignBottom="@+id/rel"        android:id="@+id/text_delete"        android:background="#ff0000"        android:text="删除"        android:gravity="center"        android:textColor="#ffffff"        android:layout_width="50dp"        android:layout_height="match_parent" /></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, heightMeasureSpec);    }}
选中或者不选中的时候
<selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:state_checked="true" android:drawable="@drawable/shopping_cart_checked"/>    <item android:state_checked="false" android:drawable="@drawable/shopping_cart_none_check"/></selector>
边框
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#ffffff"></solid>    <stroke        android:width="0.1dp"        android:color="#000000"        /></shape>

原创粉丝点击