侧边购物车的xml文件

自定义购物车布局XML详解
本文档详细介绍了自定义侧边购物车的布局实现,包括主页面布局、左右RecyclerView的布局文件、颜色资源文件以及drawable中的圆形背景XML。同时提到了购物车Bean类的相关依赖和权限设置。

自定义控件的布局在之前购物车的XML文件中

1.主页面的布局

<?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="com.example.elemo.MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal">
        <android.support.v7.widget.RecyclerView
            android:id="@+id/left_recycler"
            android:layout_width="100dp"
            android:layout_height="match_parent"
            android:background="@color/grayblack">

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

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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="80dp">

        <ImageView
            android:id="@+id/shop_car_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:src="@drawable/gouwuc_r" />
        <TextView
            android:id="@+id/goods_sum_price"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="价格:"
            android:layout_marginLeft="20dp"
            android:layout_centerVertical="true"/>

        <TextView
            android:id="@+id/goods_number"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:textSize="10sp"
            android:gravity="center"
            android:textColor="@color/white"
            android:layout_marginLeft="-10dp"
            android:background="@drawable/circle_red_bg"
            android:layout_alignParentTop="true"
            android:layout_toEndOf="@+id/shop_car_image"
            android:text="7"
            android:layout_toRightOf="@+id/shop_car_image" />
    </RelativeLayout>

</LinearLayout>

2.左边RecyclerView的布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/left_text"
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:textSize="16sp"
        android:gravity="center"
        android:textColor="@color/white"
        android:text="aa" />
</LinearLayout>

3.右边RecyclerView的布局文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/image"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:minHeight="50dp"
        android:layout_alignParentLeft="true"
        android:src="@mipmap/ic_launcher"/>

    <TextView
        android:id="@+id/text"
        android:layout_toRightOf="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="aa"
        android:padding="10dp"/>
    <TextView
        android:id="@+id/text_price"
        android:layout_toRightOf="@+id/image"
        android:layout_below="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="价格"
        android:padding="10dp"/>

    <com.example.view.AddSubLayout
        android:id="@+id/add_sub_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="20dp">

    </com.example.view.AddSubLayout>

</RelativeLayout>

4.values的color文件

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#008577</color>
    <color name="colorPrimaryDark">#00574B</color>
    <color name="colorAccent">#D81B60</color>

    <color name="white">#FFFFFF</color> <!-- 白色 -->
    <color name="black">#000000</color> <!-- 黑色 -->
    <color name="thinblue">#4186c9</color> <!-- 淡蓝色 -->
    <color name="transparent">#00000000</color> <!-- 透明 -->
    <color name="thingray">#dae8f5</color> <!-- 淡灰色 -->
    <color name="thinwhite">#c6daf0</color> <!-- 浅白色 -->
    <color name="gray">#ececec</color> <!-- 灰色 -->
    <color name="grayblack">#999999</color> <!-- 灰黑色 -->
    <color name="commonblack">#585858</color> <!-- 一般使用的黑色 -->
    <color name="line_color">#d8d8d8</color> <!-- 单调的黑色 -->
    <color name="radiocolor">#858a8e</color> <!-- 按钮颜色 -->
    <color name="custom_gray">#656565</color> <!-- 通用灰 -->
    <color name="list_black">#d0d0d0</color> <!-- 分隔线黑 -->
    <color name="fontblack">#4f4f4f</color> <!-- 字体颜色 -->
    <color name="fontgray">#5c5c5c</color> <!-- 字体灰 -->
    <color name="graybg">#efefef</color>
    <color name="gray_bg">#fbfbfb</color> <!-- 事件详情页信息背景 -->
    <color name="blackgray">#E5E5E5</color> <!-- 深灰 -->
    <color name="pure_gray">#f2f2f2</color> <!-- 纯色灰 -->
    <color name="set_font_color">#686868</color>
    <color name="set_title_color">#9a9a9a</color>
    <color name="set_account_color">#57a6d8</color>
    <color name="center_item_color">#575757</color>
    <color name="titlebar_color">#4bc1d2</color>
    <color name="set_line">#e4e4e4</color>
    <color name="blue">#145fa6</color> <!-- 蓝色 -->
    <color name="login_bg">#4cb3e8</color>
    <color name="hintcolor">#cdcdcd</color>
    <color name="tb_color">#f8f8f8</color>
    <color name="center_checked_no_color">#909090</color>
    <color name="msg_font_color">#555555</color>
    <color name="mark_red">#ff4040</color> <!-- 红色 -->
    <color name="gray_text">#666666</color>
    <color name="topic_text_color">#767676</color>
    <color name="filter_bg_color">#00FBFF</color>
    <color name="gray_thin">#adadad</color>
    <color name="topic_name_color">#6db3be</color>
    <color name="topic_reply_color">#a9a9a9</color>
    <color name="even_city_tui_color">#777678</color>
    <color name="even_near_color">#f2f1f1</color>
    <color name="even_near_small_color">#dfdfdf</color>
    <color name="even_footer_color">#989696</color>
    <color name="banner_join_press_color">#d4ecf1</color>
    <color name="tb_text_color">#4f423a</color>
    <color name="register_btn_color">#7ed321</color>
    <color name="topic_reply_time_color">#9b9b9b</color>

    <!-- 播的字体颜色 -->
    <color name="bo_small_text_color">#CCCCCC</color>
    <color name="bo_text_hint_color">#A4A4A4</color>
    <color name="body_text_1">#ff000000</color>
    <color name="body_text_2">#99000000</color>
    <color name="body_text_disabled">#66000000</color>
    <color name="body_text_1_inverse">#ffffffff</color>
    <color name="body_text_2_inverse">#99ffffff</color>
    <color name="accent_1">#ff29549f</color>
    <color name="hyperlink">#ffff549f</color>
    <color name="background_1">#ffffffff</color>
    <color name="whats_on_separator">#4d000000</color>
    <color name="all_track_color">#ff222222</color>
    <color name="block_column_1">#ff0fabff</color>
    <color name="block_column_2">#ffdf1831</color>
    <color name="block_column_3">#ff009939</color>
    <color name="umeng_fb_color_btn_pressed">#1495F7</color>
    <color name="umeng_fb_color_btn_normal">#333333</color>
    <color name="actionbar_background_start">#3A5FCD</color>
    <color name="actionbar_background_end">#27408B</color>

</resources>

5.drawable的文件夹下创建circle_red_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <solid
        android:color="#D81B60"></solid>

</shape>

侧边购物车需导入的依赖与权限在(购物车的Bean类)里

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值