问题
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