android仿抖音礼物列表实现,Android仿抖音列表效果

本文介绍了如何在Android中使用RecyclerView实现类似抖音的列表效果,包括自定义PagerLayoutManager和实现视频播放暂停的相关接口,详细代码可供参考。
摘要由CSDN通过智能技术生成

本文实例为大家分享了Android仿抖音列表效果的具体代码,供大家参考,具体内容如下

48f0f83b097e6fb128566bc92526e839.gif

当下抖音非常火热,是不是也很心动做一个类似的app吗?

那我们就用RecyclerView实现这个功能吧,关于内存的回收利用就交给RecyclerView就好了。

首先我们先说3个和视频播放暂停相关的接口

public interface OnViewPagerListener {

/**

* 初始化

*/

void onInitComplete(View view);

/**

* 释放

*/

void onPageRelease(boolean isNext, int position, View view);

/**

* 选中

*/

void onPageSelected(int position, boolean isBottom, View view);

}

然后自定义LinearLayoutManager

public class PagerLayoutManager extends LinearLayoutManager {

private PagerSnapHelper mPagerSnapHelper;

private OnViewPagerListener mOnViewPagerListener;

private RecyclerView mRecyclerView;

private int mDrift;//位移,用来判断移动方向

public PagerLayoutManager(Context context, int orientation) {

super(context, orientation, false);

init();

}

public PagerLayoutManager(Context context, int orientation, boolean reverseLayout) {

super(context, orientation, reverseLayout);

init();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值