仿饿了么购物车效果(UI效果)

本文介绍了如何在Android中实现饿了么购物车的UI效果,包括右列表标题悬停、左右列表联动以及添加购物车时的动画效果。通过使用StickyListHeadersListView开源库,实现了列表的分组展示和滑动联动。同时,详细讲解了添加购物车动画的实现过程,包括点击事件处理、坐标计算和动画设置。
摘要由CSDN通过智能技术生成

images

  • 右列表标题悬停
  • 左右列表滑动时联动
  • 添加购物车时动画效果

右列表标题悬停&左右列表滑动时联动

github开源库:StickyListHeadersListView
StickyListHeadersListView使用:http://blog.csdn.net/zuiwuyuan/article/details/49872533

gradle添加依赖

    compile 'se.emilsjolander:stickylistheaders:2.7.0'

主Layout简单,基本LinearLayout实现,左边列表直接用RecyclerView实现

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.gaoyy.stickylistdemo.MainActivity"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:layout_above="@+id/linearLayout"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:orientation="horizontal">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/left"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.3"/>

        <se.emilsjolander.stickylistheaders.StickyListHeadersListView
            android:id="@+id/list"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.7"
            />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="#433d3d"
        android:orientation="horizontal">
        <ImageView
            android:id="@+id/cart"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:padding="10dp"
            android:layout_marginLeft="10dp"
            android:src="@mipmap/icon_cart"/>

    </LinearLayout>
</RelativeLayout>

数据模拟,左Type右Sample,唯一需要注意的是,在初始化数据时,数据必须按照分组顺排列

public class Sample
{
    //item id
    private String id;
    //所属组id
    private String groupId;
    //item title
    private String title;
    //item desc
    private String desc;
    //组 title
    private String groupTitle;
    //数量
    private int count;

    public Sample(String id, String groupId, String title, String desc, String groupTitle,int count)
    {
        this.id = id;
        this.groupId = groupId;
        this.title = title;
        this.desc = desc;
        this.groupTitle = groupTitle;
        this.count= count;
    }

    //setter and getter...
}

public class Type
{
    private int status;
    private String type;

    public Type(int status, String type)
    {
        this.status = status;
        this.type = type;
    }

    //setter and getter...
}

...

private void 
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值