购物车的第二种方法的xml以及依赖和权限

版权声明:本文为宠歆小王子的原创文章,未经宠歆小王子允许不得转载。 https://blog.csdn.net/qq_41698379/article/details/83383819

//权限

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

//依赖

implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'

//main的xml

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

    <!--标题栏-->
    <RelativeLayout
        android:id="@+id/rl_title"
        android:layout_width="match_parent"
        android:layout_height="48dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="购物车" />

        <TextView
            android:id="@+id/txt_edit_or_finish"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:padding="5dp"
            android:text="编辑" />

    </RelativeLayout>

    <!--底部结算-->
    <RelativeLayout
        android:id="@+id/rl_bottom"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_alignParentBottom="true">

        <CheckBox
            android:id="@+id/cb_total_select"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:text="全选" />

        <TextView
            android:id="@+id/txt_total_price"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@id/cb_total_select"
            android:textColor="#c23636" />

        <Button
            android:id="@+id/btn_calu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:text="结算" />
    </RelativeLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_shopper"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/rl_bottom"
        android:layout_below="@id/rl_title"></android.support.v7.widget.RecyclerView>

</RelativeLayout>

//item_add_decrease

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="70dp"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/txt_decrease"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#e78b8b"
        android:padding="5dp"
        android:text=" - " />

    <TextView
        android:id="@+id/txt_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:background="#e78b8b"
        android:padding="5dp"
        android:text=" + " />

    <TextView
        android:id="@+id/txt_num"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@id/txt_add"
        android:layout_toRightOf="@id/txt_decrease"
        android:gravity="center"
        android:maxLength="3" />
</RelativeLayout>

//item_product.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingBottom="5dp"
    android:paddingLeft="20dp"
    android:paddingRight="5dp"
    android:paddingTop="5dp">

    <CheckBox
        android:id="@+id/cb_product"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@null" />

    <ImageView
        android:id="@+id/img_product"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:layout_marginLeft="10dp"
        android:layout_toRightOf="@id/cb_product" />

    <com.bwie.cart1023.widget.AddDecreaseView
        android:id="@+id/adv_product"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"></com.bwie.cart1023.widget.AddDecreaseView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/adv_product"
        android:layout_toRightOf="@id/img_product"
        android:orientation="vertical">

        <TextView
            android:id="@+id/txt_product_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp" />

        <TextView
            android:id="@+id/txt_single_price"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

</RelativeLayout>

//item_shopper

<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:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:orientation="horizontal"
        android:padding="5dp">

        <CheckBox
            android:id="@+id/cb_shopper"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@null" />

        <TextView
            android:id="@+id/txt_shopper_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_product"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </android.support.v7.widget.RecyclerView>

</LinearLayout>

猜你喜欢

转载自blog.csdn.net/qq_41698379/article/details/83383819