# SectionItemDecoration **Repository Path**: xuyougen/section-item-decoration ## Basic Information - **Project Name**: SectionItemDecoration - **Description**: Section效果简单实现 - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2021-04-25 - **Last Updated**: 2025-03-20 ## Categories & Tags **Categories**: android-modules **Tags**: RecyclerView, ItemDecoration, Android ## README # SectionItemDecoration(iOS Section效果) #### 截图 ![输入图片说明](https://images.gitee.com/uploads/images/2021/0425/152451_8eb9f233_1555343.gif "Video_20210425_032230_339.gif") #### 使用说明 ``` //根据数据类型自定义SectionProvider, 并实现getSectionImpl()方法, 返回Section对象。 DataSelectionProvider sectionProvider = new DataSelectionProvider(dataList); //默认的SectionPainter, 可实现SectionPainter接口进行自定义效果绘制 TextSectionPainter sectionPainter = new TextSectionPainter.Builder(this) .setSectionBarColor(0xffffacac) .setDividerColor(0xffff8888) .setTextColor(0xffffffff) .setTextSize(dip2px(16)) .setSectionBarHeight(dip2px(32)) .setDividerHeight(1) .build(); //创建ItemDecoration SectionItemDecoration decoration = new SectionItemDecoration(sectionProvider, sectionPainter); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.addItemDecoration(decoration); recyclerView.setAdapter(new Adapter(dataList)); ```