写一写虎扑APP首页效果,jrs都进来看一眼!

首先先上效果图:



首先我们先考虑这个界面有什么难点:

1.日期悬停。

     2.今日和其他日期在悬停布局上的处理

     3.首次进入时,自动滑动到今日比赛

     4.向上滑动向下滑动一定距离后,出现向上向下的图标,并滚动到今日的比赛界面

     5.向上加载更多,向下加载更多,当然这个并不算是难点,只是比较新颖~。


好了,首先我们一项一项的开始解决这几个难点,首先这样的列表布局,强烈推荐大家使用RecyclerView,谷歌粑粑真的是赋予了它无穷的潜力。观看本文前依然推荐一波博客地址:点击打开链接 一个头像狂魔的博客。

如果你已经看过了上篇博客,你可能会对这个界面已经有一定的了解,那么首先我们实现ItemDecoration的编写,首先我们应该考虑后台与我们交互时给出来的数据,一般为List或者Map格式,所以我们在编写时应充分考虑两种格式写法上的差异(其实也没什么差异的地方)。

public class HuPuItemDecoration<T extends HuPuBaseBean> extends RecyclerView.ItemDecoration {

    private int todayPosition;
    private List<T> mData;

    private Map<String, List<T>> mapData;

    private Paint mPaint;


    private int itemHeight;

    private int background;

    private int textSize;

    private int textColor;

    private Context context;

    private Rect outBounds = new Rect();


    public HuPuItemDecoration(Context context, int todayPosition, List<T> mData) {
        this.context = context;
        this.todayPosition = todayPosition;
        this.mData = mData;
        mPaint = new Paint();
        itemHeight = dip2px(context, 25);
        background = ContextCompat.getColor(context, android.R.color.darker_gray);
        textSize = sp2px(context, 15);
        textColor = ContextCompat.getColor(context, android.R.color.black);
    }

    public HuPuItemDecoration(Context context, int todayPosition, Map<String, List<T>> mapData) {
        this.context = context;
        this.todayPosition = todayPosition;
        this.mapData = mapData;
        mPaint = new Paint();
        itemHeight = dip2px(context, 25);
        background = ContextCompat.getColor(context, android.R.color.darker_gray);
        textSize = sp2px(context, 15);
        textColor = ContextCompat.getColor(context, android.R.color.black);
        for (Map.Entry<String, List<T>> entry : mapData.entrySet()) {
            mData.addAll(entry.getValue());
        }
    }
这里的HuPuBaseBean是一个bean类,内部实现了getDayType的方法,这里是基于封装而写出的基类,如果在实际项目中可以直接引入我们所需要的实体类来进行赋值。

初始化完成后,我们开始一步一步实现:代码很简单,一梭子给出来一部分先:

关于这部分方法的意义,推荐大家去鸿洋sama的博客去充值信仰!!!:

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值