How do I make WRAP_CONTENT work on a RecyclerView

后端 未结 19 1839
自闭症患者
自闭症患者 2020-11-22 12:49

I have a DialogFragment that contains a RecyclerView (a list of cards).

Within this RecyclerView are one or more CardVi

19条回答
  •  日久生厌
    2020-11-22 13:44

    Replace measureScrapChild to follow code:

    private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
            int heightSpec, int[] measuredDimension)
        {
            View view = recycler.GetViewForPosition(position);
            if (view != null)
            {
                MeasureChildWithMargins(view, widthSpec, heightSpec);
                measuredDimension[0] = view.MeasuredWidth;
                measuredDimension[1] = view.MeasuredHeight;
                recycler.RecycleView(view);
            }
        }
    

    I use xamarin, so this is c# code. I think this can be easily "translated" to Java.

提交回复
热议问题