RecycleView设置分割线DividerItemDecoration

教程大全  / 倒序浏览   ©

#楼主# 2020-2-20

跳转到指定楼层

马上注册,分享更多源码,享用更多功能,让你轻松玩转云大陆。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

实际上是继承RecyclerView.ItemDecoration

1.用体系提供的                                                                                                                                                           DividerItemDecoration dec=newDividerItemDecoration(mContext,DividerItemDecoration.VERTICAL);

2.DividerItemDecoration 可以通过setDrawable(Drawable drawable)来设置具体的分割线内容    DividerItemDecoration.setDrawable(newColorDrawable(ContextCompat.getColor(mContext,R.color.bg_xxx)));

3.自定义shape可以设置分割线                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Drawable drawable = ContextCompat.getDrawable(mContext,R.drawable.shape_question_diveder);

4.使用drawable设置分割线的高度和颜色                                                                                                                  Drawable drawable = ContextCompat.getDrawable(mContext,R.mipmap.ic_launcher);          DividerItemDecoration.setDrawable(Drawable drawable)

分享淘帖
回复

使用道具

您的回复是对作者最大的奖励

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关于作者

13985759690

新手猿

  • 主题

    5

  • 帖子

    5

  • 关注者

    0

Archiver|手机版|小黑屋|云大陆 | 赣ICP备18008958号-4|网站地图
Powered by vrarz.com!  © 2019-2020版权所有云大陆