This is an implementation of AccordionView in Android using ConstraintLayout and ConstraintSet.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


icons are taken from

This is an implementation of AccordionView in Android using ConstraintLayout and ConstraintSet.

click to show gif

How to setup

allprojects {
    repositories {
	maven { url '' }
dependencies {
    implementation 'com.github.worker8:AccordionView:VERSION'

Replace the VERSION with the latest one you can find here:


implementation 'com.github.worker8:AccordionView:1.0.x'

You can exclude the support library and use your own version if you face some conflict:

implementation("com.github.worker8:AccordionView:$libVersions.accordionView") {
    exclude group: ''

How to use

To use AccordionView, you can refer to the example in this repo:

It works very similarly to RecyclerView.

Include in xml

First you need to include it in the xml. Example can be found here

<?xml version="1.0" encoding="utf-8"?>
< xmlns:android=""

        app:layout_constraintTop_toTopOf="parent" />

AccordionView is a child of ConstraintLayout. However, don't include any children inside AccordionView, the behavior will be unexpected.

Instead, supply the data using AccordionAdapter.


AccordionAdapter is the supplier of data. for AccordionView. Example can be found here.

It works similarly to RecyclerView.Adapter:

AccordionAdapter has 5 methods to be overriden:

    fun onCreateViewHolderForTitle(parent: ViewGroup): AccordionView.ViewHolder
    fun onCreateViewHolderForContent(parent: ViewGroup): AccordionView.ViewHolder
    fun onBindViewForTitle(viewHolder: AccordionView.ViewHolder, position: Int, arrowDirection: ArrowDirection)
    fun onBindViewForContent(viewHolder: AccordionView.ViewHolder, position: Int)
fun getItemCount(): Int

view creation

onCreateViewHolderForTitle and onCreateViewHolderForContent are used for view creation:


view binding

onBindViewForTitle and onBindViewForContent on the other hand are used for view binding, such as: setting up the data, and setting up listeners, loading images, etc.

data count

getItemCount on the other hand tells AccordionView how many items you have.

The Implementation Details of AccordionView

Refer to this blog post where I described in depth:


This view does not take into account if you supply too many data and fill up the screen, it is best used for cases where you only have a few items to be shown.