仿抖音、快手、短视频,竖直方向,一次滚动一个页面的封装库。目前支持ViewPager做法,也支持RecyclerView做法……使用ViewPager只需修改滑动速率和滚动翻页过渡时间;使用recyclerView打造丝滑切换视频的功能,更多内容可参考demo
仿抖音、快手、短视频,竖直方向,一次滚动一个页面的封装库。目前支持ViewPager做法,也支持RecyclerView做法……使用ViewPager只需修改滑动速率和滚动翻页过渡时间;使用recyclerView打造丝滑切换视频的功能,更多内容可参考demo
implementation 'com.github.yangchong211:YCScrollPager:1.0.5'private void initViewPager() {
List list = new ArrayList<>();
ArrayList fragments = new ArrayList<>();
//数据源注意,使用的时候替换成你的,这里设置一些假数据
for (int a = 0; a list;
public MyPagerAdapter(ArrayList list , FragmentManager fm){
super(fm);
this.list = list;
}
@Override
public Fragment getItem(int i) {
return list.get(i);
}
@Override
public int getCount() {
return list!=null ? list.size() : 0;
}
}…PagerLayoutManager viewPagerLayoutManager = new PagerLayoutManager(
this, OrientationHelper.VERTICAL);
recyclerView.setLayoutManager(viewPagerLayoutManager);……try {
//attachToRecyclerView源码上的方法可能会抛出IllegalStateException异常,这里手动捕获一下
RecyclerView.OnFlingListener onFlingListener = mRecyclerView.getOnFlingListener();
//源码中判断了,如果onFlingListener已经存在的话,再次设置就直接抛出异常,那么这里可以判断一下
if (onFlingListener==null){
mPagerSnapHelper.attachToRecyclerView(mRecyclerView);
}
} catch (IllegalStateException e){
e.printStackTrace();
}Copyright 2017 yangchong211(github.com/yangchong211)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.暂无开放 Issues,或尚未同步最近议题。