[英]Expand and Collapse cards in RecyclerView
i'm working on a RecyclerView in Android which should contains expandable cards.我正在 Android 中开发一个 RecyclerView,它应该包含可扩展的卡片。 I've already seen some questions like this or this but I can't figure out how to manage some things.
我已经看到了一些这样或这样的问题,但我不知道如何管理一些事情。
In my app (pic below) the expandable part is the one with the "maps" icon and "plus" icon.在我的应用程序(下图)中,可扩展部分是带有“地图”图标和“加号”图标的部分。
During Google I/O 2016, Nick Butcher explained some of his code but i can't solve the part in which he divides the layout in two parts (the one that is always visibile itemView , and the expandable one, details ) in the onBindViewHolder method.在谷歌I / O 2016年, 尼克·布彻解释了他的一些代码,但我不能解决他在onBindViewHolder划分布局分为两个部分(就是那个永远都看得到ItemView控件,以及可扩展的一个,细节)的一部分方法。
final boolean isExpanded = position==mExpandedPosition;
holder.details.setVisibility(isExpanded?View.VISIBLE:View.GONE);
holder.itemView.setActivated(isExpanded);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mExpandedPosition = isExpanded ? -1:position;
TransitionManager.beginDelayedTransition(recyclerView);
notifyDataSetChanged();
}
});
Can anyone explain me this and the other parts that make the animation and the expansion possible?任何人都可以向我解释这个以及使动画和扩展成为可能的其他部分吗? You could find useful the Heisenberg's reply in this question Thanks!
您可以在此问题中找到有用的海森堡答复 谢谢!
确定解决:识别布局中的“隐藏”部分并将其保存在视图中就足够了。
尝试在 viewholder 构造函数中添加隐藏部分并膨胀管理它的视图
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.