skydoves / ExpandableLayout

🦚 An expandable layout that shows a two-level layout with an indicator.
Apache License 2.0
828 stars 54 forks source link

The lib has weird issues in RecyclerView #33

Open chihung93 opened 2 years ago

chihung93 commented 2 years ago

Please complete the following information:

Describe the Bug: I have attached the reproduced video and code

https://user-images.githubusercontent.com/5199109/153915619-ce1c4240-c2be-4f74-965b-b2ab5f1b3f13.mp4


/*
 * Copyright (C) 2019 skydoves
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.skydoves.expandablelayoutdemo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.skydoves.expandablelayoutdemo.databinding.ActivityCustomBinding
import kotlin.random.Random

class CustomActivity : AppCompatActivity() {

  private val adapter = ParentAdapter()

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    val binding = ActivityCustomBinding.inflate(layoutInflater)
    setContentView(binding.root)

    binding.recyclerView.adapter = adapter
    for (i in 0..100){
      val child = ArrayList<String>()
      val randomValues = List(10) { Random.nextInt(0, 50) }
      randomValues.forEach {
        child.add("child $i")
      }
      adapter.addSectionItem(
        SectionItem("Title $i", R.color.colorPrimary, child)
      )
    }

  }
}

Expected Behavior:

As demo sample