代码拉取完成,页面将自动刷新
// 1. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
// 2. Add the dependency in your app/build.gradle
dependencies {
compile 'com.github.fashare2015:StackLayout:1.0.0'
}
clipChildren="false"
, 使之能全屏拖动<RelativeLayout
...
android:clipChildren="false">
<com.fashare.stack_layout.StackLayout
android:id="@+id/stack_layout"
android:layout_width="match_parent"
android:layout_height="500dp"/>
</RelativeLayout>
用法基本同RecyclerView,不赘述。
mStackLayout = (StackLayout) findViewById(R.id.stack_layout);
mStackLayout.setAdapter(mAdapter = new MyAdapter(mData = new ArrayList<>()));
// 刷新数据
mData.addAll(...);
mAdapter.notifyDataSetChanged();
内置了三个效果,即gif效果图上的效果。
mStackLayout.addPageTransformer(
new StackPageTransformer(), // 堆叠
new AlphaTransformer(), // 渐变
new AngleTransformer() // 角度
);
自定义:根据position区分状态,做相应的动画。详见demo和接口注释。
position | 状态 |
---|---|
[-1, -1] | 完全移出屏幕, 待remove状态 |
(-1, 0) | 手指拖动状态 |
[0, 栈内页面数) | 栈中状态 |
[栈内页面数, 总页面数) | 显示不下, 待显示状态 |
接口作用:(各参数定义见接口注释)
loadmore
动作mStackLayout.setOnSwipeListener(new StackLayout.OnSwipeListener() {
@Override
public void onSwiped(View swipedView, int swipedItemPos, boolean isSwipeLeft, int itemLeft) {
toast((isSwipeLeft? "往左": "往右") + "移除" + mData.get(swipedItemPos) + "." + "剩余" + itemLeft + "项");
// 少于5条, 加载更多
if(itemLeft < 5){
// TODO: loadmore
}
}
});
https://github.com/flschweiger/SwipeStack
https://github.com/xiepeijie/SwipeCardView
https://github.com/mcxtzhang/ZLayoutManager
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。