• Stars
    star
    212
  • Rank 185,406 (Top 4 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

京东首页 - 长列表内嵌ViewPager商品流(CoordinatorLayout方案)

PersistentCoordinatorLayout

仿京东首页,整体是个长列表,内嵌子列表-商品feeds流(PersistentRecyclerView),且商品流可以左右滑动。

实现效果

点击可查看截屏视频

使用方法

  1. 外部的长列表容器使用PersistentCoordinatorLayout;
  2. 内嵌的子列表使用PersistentRecyclerView;

CoordinatorLayout和RecyclerView的使用方法跟官方一样,ViewPager和ViewPager2可随意选用,均已内部兼容;

实现方案

CoordinatorLayout已经实现了NestedScrollingParent3接口,当底部商品流列表上拉或下拉时,会自动将Fling的速率传递给AppBarLayout。而AppBarLayout上拉触底时,却无法将Fling速率传递给底部的商品流RecyclerView。所以,我们只要能改造好这一点,就能让CoordinatorLayout“更像是一个长列表”。

要实现这一点并不复杂,AppBarLayout的fling是通过behavior实现的,behavior内部会维护一个OverScroller对象,OverScroller保存了我们想要的一切,包括Fling速率和滑行时间。我们只要能在正确的时间,把正确的Fling速率传递好,就能让CoordinatorLayout实现的长列表毫无违和感!

仓库中细节代码较多,此处不再赘述,感兴趣的同学可自行Review代码即知。

另一种方案

京东App首页的长列表,整体是通过RecyclerView实现的,我也实现了一份,感兴趣的同学可以去瞅瞅:传送门

Demo下载

点击下载

More Repositories

1

ViewpagerTransition

viewpager with parallax pages, together with vertical sliding (or click) and activity transition
Java
3,039
star
2

CardSlidePanel

enable users to slide card to the left or right smoothly and continuously
Java
2,385
star
3

AndroidPileLayout

An abnormal horizontal ListView-like pile layout with stretch and contraction effects.
Java
2,157
star
4

VegaLayoutManager

√A customized LayoutManager - fade and shrink the head itemView when scrolling.
Java
1,859
star
5

VerticalSlideFragment

vertical slide to switch to the next fragment page, looks like vertical viewpager
Java
1,606
star
6

DragRankSquare

edit personal information which enables users to drag and rank image order
Java
1,118
star
7

AnimRichEditor

rich text editor which enables users to insert/delete bitmaps and text into edit-view with animations.
Java
976
star
8

android-snake-menu

imitate Tumblr's menu, dragging animations look like a snake
Java
584
star
9

stickyViewpager

[deprecated] sticky view in viewpager which includes scrollview and listview - viewpager with headers
Java
313
star
10

PersistentRecyclerView

京东首页 - 长列表内嵌ViewPager商品流(RecyclerView方案)
Kotlin
308
star
11

android-character-animation

in textview, characters come along one by one with random alpha animation
Java
59
star
12

android-slide-to-unlock

imitate ios, slide to unlock, text color gradient animation
Java
47
star
13

AutoWrapLayout

a customized viewgroup wraps textviews and aligns on both left and right sides.
Java
46
star
14

boringArticles

just some articles
19
star
15

MailExtension

chrome插件 - 工资条助手
JavaScript
14
star