RecyclerView不能随其项目缩放 [英] RecyclerView doesn't scale with its item

查看:152
本文介绍了RecyclerView不能随其项目缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是该问题的示例 github rep RecyclerView

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

我正在按点击缩放RecyclerView

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:

  • 尽管RecyclerView的高度为android:layout_height="wrap_content",但它本身不会对单击的项目的新大小做出反应.

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

我可能会使用

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

并避免切割视图,但这会显示溢出项,这也是不希望的选项,因此我也在努力寻找RecyclerView随比例增长的方法.

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

我曾尝试更改RV的高度,但只有与顶部和底部逐渐增大的缩放效果相比,它才向下拉.

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.

推荐答案

您尚未共享RecyclerView和列表项的布局.您呼吁如果可能的话.因此,我建议您看一下可扩展的RecyclerView,其中每个项目在单击它们时都会扩展.

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.

这是一个漂亮的库,用于创建所需的可扩展RecyclerView.

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.

这篇关于RecyclerView不能随其项目缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆