RecyclerView doesn't scale with its item

…衆ロ難τιáo~ 提交于 2020-01-06 08:24:19

问题


Here's github rep example of the issue and the RecyclerView adapter for your convenience.

I am scaling RecyclerView item on click

imageView.setOnClickListener {
    val pivotType = Animation.RELATIVE_TO_SELF
    val scaleAnime = ScaleAnimation(1f,2f,1f,2f,
            pivotType, 0.5f, pivotType, 0.5f )

    scaleAnime.duration = 400
    scaleAnime.fillAfter = true
    ViewCompat.setElevation(it,1f)
    it.startAnimation(scaleAnime)
}

However, I'm struggling with the following issues:

  • The RecyclerView itself doesn't react to the clicked item new size although it's height is android:layout_height="wrap_content".

    I might use

    android:clipChildren="false"
    android:clipToPadding="false"
    

    and avoid the cutting of the view but that would reveal the overflow items which isn't desired option as well so I'm struggling to find a way for the RecyclerView to grow with the scale, too.

  • The scaled item overlaps over it's neighbor items instead of pushing them away

I have tried changing the height of the RV but it grows downward only compare to scale effect which grows top and bottom.

Anybody who has idea how to resolve these issues please share or even suggest an alternative.


回答1:


You have not shared the layouts of your RecyclerView and the list items. You called for an alternative if possible. Hence I suggest you might take a look at expandable RecyclerView where each item will expand on clicking on them.

Here's a nice library for creating the expandable RecyclerView that you want.

You might consider looking into this one as well. The implementations are simple.



来源:https://stackoverflow.com/questions/48909654/recyclerview-doesnt-scale-with-its-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!