All Projects → HitenDev → Jkcardlayout

HitenDev / Jkcardlayout

高仿即刻APP探索页卡片布局拖拽、卡片前进、回退和下拉效果,采用RecyclerView和自定义LayoutManager实现

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Jkcardlayout

Horizontalpicker
A simple, customizable and easy to use picker where centre view is scaled up
Stars: ✭ 337 (+203.6%)
Mutual labels:  layoutmanager, recyclerview
Reel Search Android
Reel Search for Android is a UI/UX design for autocomplete action. It is a beautiful minimalistic addition to any use case.
Stars: ✭ 110 (-0.9%)
Mutual labels:  layoutmanager, recyclerview
Stacklayoutmanager
customized layoutmanager,let item pile up like stackview/类似最美有物卡片堆叠效果
Stars: ✭ 343 (+209.01%)
Mutual labels:  layoutmanager, recyclerview
SlideView
🔖 Card RecycleViewManager, to make your interface cool.Use recyclerView to add cool effects to the view.
Stars: ✭ 16 (-85.59%)
Mutual labels:  recyclerview, layoutmanager
Timetablelayout
TimetableLayout is a RecyclerView.LayoutManager to display the timetable for Android.
Stars: ✭ 726 (+554.05%)
Mutual labels:  layoutmanager, recyclerview
SpannedGridLayoutManager
Android RecyclerView.LayoutManager that resizes and reorders views based on SpanSize
Stars: ✭ 522 (+370.27%)
Mutual labels:  recyclerview, layoutmanager
Spannedgridlayoutmanager
Android RecyclerView.LayoutManager that resizes and reorders views based on SpanSize
Stars: ✭ 492 (+343.24%)
Mutual labels:  layoutmanager, recyclerview
RollingLayoutManager
vrgsoft.net
Stars: ✭ 57 (-48.65%)
Mutual labels:  recyclerview, layoutmanager
Gallerylayoutmanager
New way to implements ViewPager/Gallery in Android with RecycleView
Stars: ✭ 684 (+516.22%)
Mutual labels:  layoutmanager, recyclerview
Discretescrollview
A scrollable list of items that centers the current element and provides easy-to-use APIs for cool item animations.
Stars: ✭ 5,533 (+4884.68%)
Mutual labels:  layoutmanager, recyclerview
InfiniteScrollRecyclerView
Enables the RecyclerView to Auto scroll for indefinite time.
Stars: ✭ 49 (-55.86%)
Mutual labels:  recyclerview, layoutmanager
Turn Layout Manager
A carousel layout manager for RecyclerView
Stars: ✭ 946 (+752.25%)
Mutual labels:  layoutmanager, recyclerview
epg magic carousel
Awesome RecyclerView with custom LayoutManager
Stars: ✭ 98 (-11.71%)
Mutual labels:  recyclerview, layoutmanager
Chipslayoutmanager
ANDROID. ChipsLayoutManager (SpanLayoutManager, FlowLayoutManager). A custom layout manager for RecyclerView which mimicric TextView span behaviour, flow layouts behaviour with support of amazing recyclerView features
Stars: ✭ 3,138 (+2727.03%)
Mutual labels:  layoutmanager, recyclerview
CardLayoutManager
A custom layoutManager providing a Tinder-like cards effect.
Stars: ✭ 37 (-66.67%)
Mutual labels:  recyclerview, layoutmanager
Stackcardlayoutmanager
Stars: ✭ 376 (+238.74%)
Mutual labels:  layoutmanager, recyclerview
Carouselrecyclerview
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.
Stars: ✭ 107 (-3.6%)
Mutual labels:  layoutmanager, recyclerview
Cardstackview
📱Tinder like swipeable card view for Android
Stars: ✭ 1,850 (+1566.67%)
Mutual labels:  layoutmanager, recyclerview
Awesome Recyclerview Layoutmanager
RecyclerView-LayoutManager Resources
Stars: ✭ 581 (+423.42%)
Mutual labels:  layoutmanager, recyclerview
Focuslayoutmanager
有焦点item的水平/垂直滚动RecyclerView-LayoutManager。仿Android豆瓣书影音“推荐“频道列表布局
Stars: ✭ 772 (+595.5%)
Mutual labels:  layoutmanager, recyclerview

重要提示:该交互flutter实现已经开源,快来围观:https://github.com/HitenDev/FlutterDragCard

----------以下正文----------

JKCardLayout

本项目使用RecyclerView和自定义LayoutManager等方法实现即刻App探索页交互,支持卡片拖拽,卡片回退栈管理,下拉展示菜单等功能;欢迎大家点赞或者吐槽。

代码大部分使用Kotlin语言编写,假装娴熟,如有使用不当还请各路大神指点。

下载Demo

下载地址:https://www.pgyer.com/yZ2L

效果展示

视频

https://youtu.be/GY_YVJGgKtk

图片

如何使用

implementation 'me.hiten:jkcardlayout:0.1.1'

卡片布局辅助类CardLayoutHelper

绑定RecyclerView

mCardLayoutHelper = CardLayoutHelper<T>()
mCardLayoutHelper.attachToRecyclerView(recycler_view)

绑定数据源List

mCardLayoutHelper.bindDataSource(object : CardLayoutHelper.BindDataSource<T> {
     override fun bind(): List<T> {
         return list
     }
 })

绑定数据源采用回调接口形式,需要返回绑定的RecyclerView对应Adapter下的数据源List

卡片参数配置

val config = CardLayoutHelper.Config()
        .setCardCount(2)
        .setMaxRotation(20f)
        .setOffset(8.dp)
        .setSwipeThreshold(0.2f)
        .setDuration(200)

mCardLayoutHelper.setConfig(config)

CardLayoutHelper.Config接受参数配置,主要参数含义:

  • cardCount //卡片布局最多包含卡片个数,默认是2个
  • offset //卡片之间的偏移量,单位是像素
  • duration //卡片动画执行时间
  • swipeThreshold //拖拽卡片触发移除的阈值
  • maxRotation //拖拽过程中最大旋转角度(角度制)

行为操作(Back和Next)

//check and doNext
if (mCardLayoutHelper.canNext()) {
    mCardLayoutHelper.doNext()
}
//check and doBack
if (mCardLayoutHelper.canBack()){
    mCardLayoutHelper.doBack()
}

//check noBack
if (mCardLayoutHelper.noBack()){
    super.onBackPressed()
}

结合即刻案例,提供了Back和Next两种操作,使用前建议调用canXXX()进行判断

回调监听

mCardLayoutHelper.setOnCardLayoutListener(object :OnCardLayoutListener{
    override fun onSwipe(dx: Float, dy: Float) {
        Log.d("onStateChanged","dx:$dx dy:$dy")
    }
    override fun onStateChanged(state: CardLayoutHelper.State) {
        Log.d("onStateChanged",state.name)
    }
})
  • onSwipe(dx: Float, dy: Float) //卡片滑动距离回调
  • onStateChanged(state: CardLayoutHelper.State)//卡片状态监听,State详解
  • State.IDLE //默认状态,无拖拽和动画执行
  • State.SWIPE //手指拖动状态
  • State.BACK_ANIM //Back动画执行中,包含两种情况(释放手势卡片缓慢回到默认位置过程、调用back方法执行动画)
  • State.LEAVE_ANIM //LEAVE动画执行中,包括两种情况(释放手势卡片缓慢移除布局过程、调用next方法执行动画)

仿即刻下拉手势布局:PullDownLayout

基本功能设置

//设置阻尼
pull_down_layout.setDragRatio(0.6f)
//设置视觉差系数
pull_down_layout.setParallaxRatio(1.1f)
//设置动画时长
pull_down_layout.setDuration(200)

注意PullDownLayout类不在library中,如果需要使用的话,建议您clone一份代码改巴改巴

声明

本项目是个人作品,仅用作技术学习和开源交流,涉及到即刻APP相关的接口数据和图片资源禁止用于任何商业用途;如有疑问,请联系我。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].