简单说一下原理,当RecycleView处于停滞状态的时候,通过findFirstVisibleItemPosition() findLastVisibleItemPosition()取出所有可视的Item,通过recyclerView.getChildAt(i)取出相应的Item的布局recyclerView.getChildAt(0)取出的永远是当前可见的第一个,在对所有的可见的item中的视频播放控件的可见区域作对比这里是通过Rect作比较的,如果有多个完整可见的视频播放控件,则可以比较视频播放控件是否在屏幕中央,距离屏幕中央的距离确认。
/** * Created by LengYue on 2017/9/16. */ public class VideoPlayListener extends RecyclerView.OnScrollListener { private static final String TAG = "VideoPlayListener"; private ArrayList<View> mViews; private IDataType mDataType; public VideoPlayListener(IDataType mDataType) { super(); mViews = new ArrayList<>(); this.mDataType = mDataType; } @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); LinearLayoutManager manager = (LinearLayoutManager) recyclerView....