android抖音评论列表,BottomSheetBehavior+CoordinatorLayout实现抖音评论列表滑动效果

效果图

1cee88ea0e35

bottomsheet.gif

最近项目有这个需求, 自己能想出的最简单直接的实现办法, 稍稍改动也能支持ListView的情况.

效果说明

支持列表滑动

只有当列表滑动到顶端时, 继续下滑, 才会收起整个评论列表. 否则只是评论列表滑动.

如果设置了评论列表的标题, 可以通过拖动标题直接收起整个评论列表, 这时不再考虑评论列表是否滑动到顶部.

实现说明

所有的都在这个xml布局文件中

xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

android:id="@+id/startBtn"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerHorizontal="true"

android:layout_marginTop="40dp"

android:text="评论列表" />

android:id="@+id/bottom_sheet"

android:layout_width="match_parent"

android:layout_height="348dp"

android:orientation="vertical"

app:behavior_hideable="true"

app:behavior_peekHeight="0dp"

app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

android:id="@+id/list_title_tv"

android:layout_width="match_parent"

android:layout_height="48dp"

android:background="#3300ff00"

android:gravity="center"

android:text="这个是标题,可以拖住滑动" />

android:id="@+id/recyclerView"

android:layout_width="match_parent"

android:layout_height="300dp">

完整代码:

如果你看了这篇文章, 我猜想你可能对抖音的视频上下页切换播放也赶兴趣, 那么请也看看我的这个小demo

https://github.com/shaopx/MyDouYin

使用exoplayer实现的播放, 预加载, 很流畅

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值