Skip to content

A custom layoutManager providing a Tinder-like cards effect.

License

Notifications You must be signed in to change notification settings

adgvcxz/CardLayoutManager

Repository files navigation

CardLayoutManager

简单、可扩展的一个LayoutManager,实现了类似于探探和Tinder,滑动图片

  • 监听滑动中的事件与动画过程
  • 支持smoothScrollToPositionscrollToPosition
  • 自定义LinearLayout.HORIZONTAL或者LinearLayout.VERTICAL
  • 自定义显示卡片个数以及卡片之间的间隙
  • 自定义显示卡片的排列方向: LEFT RIGHT TOP BOTTOM
  • 自定义滑动方向: setVerticalSwipe setHorizontalSwipe
  • 对滑动过程进行控制
  • 简单易用,扩展性高

预览

滑动smoothScrollToPosition

初始化

CardLayoutManager layoutManager = new CardLayoutManager();
recyclerView.setLayoutManager(layoutManager);
new CardSnapHelper().attachToRecyclerView(recyclerView);

监听滑动事件

layoutManager.setOnCardSwipeListener(new OnCardSwipeListener() {
	......
}

自定义滑动控制

如果只是在smoothScrollToPosition不想随机卡片的起点和终点可以继承BaseCardSwipeController重写其中的方法

如果想完全控制整个滑动,则需要继承CardSwipeController实现其中所有方法

导入

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    compile 'com.github.adgvcxz:cardlayoutmanager:0.2.1'
}

感谢

ChipsLayoutManager

FanLayoutManager

LICENSE

Copyright 2016 adgvcxz

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.