布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:orientation="vertical" tools:context=".MainActivity"> <android.support.v7.widget.RecyclerView android:id="@+id/shop_recy" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" ></android.support.v7.widget.RecyclerView> <RelativeLayout android:layout_width="match_parent" android:layout_height="50dp"> <CheckBox android:id="@+id/shop_check" android:layout_width="wrap_content" android:layout_height="match_parent" android:text="全选/反选" /> <Button android:id="@+id/shop_button" android:layout_width="50dp" android:layout_height="match_parent" android:text="结算" android:background="#ff00" android:layout_alignParentRight="true" android:gravity="center_vertical" /> <TextView android:id="@+id/shop_text" android:layout_width="wrap_content" android:layout_height="match_parent" android:text="总计" android:layout_marginRight="100dp" android:layout_toLeftOf="@id/shop_button" android:gravity="center_vertical" /> </RelativeLayout> </LinearLayout>
适配器1布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:id="@+id/ll_shopcart_header" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <CheckBox android:id="@+id/base1_ck" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawablePadding="5dp" android:text=" " android:paddingBottom="10dp" android:paddingLeft="15dp" android:paddingRight="15dp" android:paddingTop="10dp" /> <TextView android:id="@+id/base1_text" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="3" android:drawablePadding="5dp" android:padding="10dp" android:text="宝儿家服装" /> </LinearLayout> </LinearLayout> <android.support.v7.widget.RecyclerView android:id="@+id/recy_view" android:layout_width="match_parent" android:layout_height="wrap_content"> </android.support.v7.widget.RecyclerView> <View android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ff00" /> <!----> </LinearLayout> 适配器2布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="135dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="horizontal"> <CheckBox android:id="@+id/base2_ck" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:drawablePadding="5dp" android:padding="15dp" /> <ImageView android:id="@+id/base_img" android:layout_width="65dp" android:layout_height="65dp" android:src="@drawable/ic_launcher_background" android:layout_margin="4dp" /> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:id="@+id/base2_text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingTop="10dp" android:text="穿秋装情侣字母徽章风衣" /> <TextView android:id="@+id/base2_text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="10dp" android:text="¥185" android:textSize="15sp" /> </LinearLayout> </LinearLayout> <com.example.shop.MyView android:id="@+id/myview" android:layout_width="wrap_content" android:layout_height="wrap_content"></com.example.shop.MyView> </LinearLayout>
自定义view布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/num_bu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="一" /> <TextView android:id="@+id/num_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1" /> <Button android:id="@+id/num_b2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="十" /> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/num_bu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="一" /> <TextView android:id="@+id/num_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1" /> <Button android:id="@+id/num_b2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="十" /> </LinearLayout>