这是否有可能将两个RecyclerView叠加在一起,并使它们都可以被点击?

huangapple go评论82阅读模式
英文:

is it possible to have two RecyclerViews on top of each other and make them both clickable?

问题

我的 XML 文件: recyclerViewOverlay 是用来放置空白的图像框架的。recyclerView 包含了实际的图像。

模拟器截图:

我的问题: 当我在 recyclerView 中添加了一个实际的图像,例如在位置 0,我将 recyclerViewOverlay 的位置 0 设置为 view.GONE,然而,即使我将 recycrlerViewOverlay 的位置设置为 GONE,我仍然无法点击位于 recyclerView 中的位置 0。

RecyclerView.ViewHolder viewHolder = recyclerViewOverlay.findViewHolderForAdapterPosition(0);
View view = viewHolder.itemView;
view.setVisibility(View.GONE);
英文:

My XML file: recyclerViewOverlay is to have empty image frames. recyclerView holds the actual images.
这是否有可能将两个RecyclerView叠加在一起,并使它们都可以被点击?

Emulator screenshot:

这是否有可能将两个RecyclerView叠加在一起,并使它们都可以被点击?

My problem: When I add an actual image in the recycleView e.g. in position 0 I set the recyclerViewOverlay position 0 to view.GONE, however, I still cannot click on position 0 that is in the recyclerView even though I am setting the position of recycrlerViewOverlay to GONE like this:

RecyclerView.ViewHolder viewHolder = recyclerViewOverlay.findViewHolderForAdapterPosition(0);
View view = viewHolder.itemView;
view.setVisibility(View.GONE);

答案1

得分: 1

不要将两个 RecyclerView 叠加在一起。相反,在您的 RecyclerView.AdapteronBindViewHolder() 中设置占位图像和实际图像。注意:为了使用占位图像,您需要预先知道图像的数量。

英文:

Don't put 2 RecyclerView's on top of each other. Instead set placeholder and actual images in onBindViewHolder() in your RecyclerView.Adapter. Note: In order to use placeholders you need to know the number of images upfront.

huangapple
  • 本文由 发表于 2020年7月23日 22:55:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/63057160.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定