I have a RecyclerView that contains a list of cards, which expand into child cards. Each card has different text. I want that when the user clicks on a child card, it expands to show the text inside. I tried to measure the target height by using:
view.Measure(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); And then expanding the card to the Measured Height (see here <http://stackoverflow.com/questions/4946295/android-expand-collapse-animation>). However, it gives the same Measured Height to all of the cards. Here is my code, which is based on this <https://github.com/bignerdranch/expandable-recycler-view> (more specifically the Xamarin version <https://github.com/frankcalise/XamDroid.ExpandableRecyclerView>): This is the main Adapter, which creates and binds the parent and the child cards: public class HalachaExpandableAdapter : ExpandableRecyclerAdapter<HalachaParentViewHolder, HalachaChildViewHolder>, View.IOnClickListener{ LayoutInflater _inflater; bool expand; int targetHeight; bool wave = false; public HalachaExpandableAdapter(Context context, List<IParentObject> itemList) : base(context, itemList) { _inflater = LayoutInflater.From(context); } public override void OnBindChildViewHolder(HalachaChildViewHolder childViewHolder, int position, object childObject) { var halachaChild = (HalachaChild)childObject; childViewHolder.halachaChildTitle.Text = halachaChild.Title.ToString(); targetHeight = childViewHolder.halachaChildCard.Height; childViewHolder.halachaChildCard.LayoutParameters.Height = 100; childViewHolder.halachaChildCard.SetOnClickListener(this); expand = childViewHolder.expand; } public override void OnBindParentViewHolder(HalachaParentViewHolder parentViewHolder, int position, object parentObject) { var halacha = (HalachaItem)parentObject; parentViewHolder._halachaTitleTextView.Text = halacha.Title(); parentViewHolder._halachaContentTextView.Text = halacha.Content; if (halacha.ChildObjectList.Count == 1) wave = true; } public void OnClick(View v) { if (v.Height == 100) { AnimationCollapse anim = new AnimationCollapse(v, targetHeight, 100); anim.Duration = 300; v.StartAnimation(anim); expand = false; } else { AnimationCollapse anim = new AnimationCollapse(v, 100, v.Height); anim.Duration = 300; v.StartAnimation(anim); expand = true; } } public override HalachaChildViewHolder OnCreateChildViewHolder(ViewGroup childViewGroup) { var view = _inflater.Inflate(Resource.Layout.halachotListItem, childViewGroup, false); return new HalachaChildViewHolder(view); } public override HalachaParentViewHolder OnCreateParentViewHolder(ViewGroup parentViewGroup) { var view = _inflater.Inflate(Resource.Layout.halachotListHeader, parentViewGroup, false); wave = false; return new HalachaParentViewHolder(view); }} I think this is where the code is needed to be done, but if you need some of the other code of the other classes, I will gladly post them. You can also look at the links above for reference to how this works. Hope someone can help me. Thanks! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/e8502281-98d4-4948-b446-34e6acac88d7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

