|
@@ -76,21 +76,25 @@ public class FullyLinearLayoutManager extends LinearLayoutManager {
|
|
|
private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
|
|
|
int heightSpec, int[] measuredDimension) {
|
|
|
try {
|
|
|
- View view = recycler.getViewForPosition(position);//fix 动态添加时报IndexOutOfBoundsException
|
|
|
+ if (position > 0) {
|
|
|
+ if (heightSpec <= 0) {
|
|
|
+ View view = recycler.getViewForPosition(position);//fix 动态添加时报IndexOutOfBoundsException
|
|
|
|
|
|
- if (view != null) {
|
|
|
- RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
|
|
|
+ if (view != null) {
|
|
|
+ RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
|
|
|
|
|
|
- int childWidthSpec = ViewGroup.getChildMeasureSpec(widthSpec,
|
|
|
- getPaddingLeft() + getPaddingRight(), p.width);
|
|
|
+ int childWidthSpec = ViewGroup.getChildMeasureSpec(widthSpec,
|
|
|
+ getPaddingLeft() + getPaddingRight(), p.width);
|
|
|
|
|
|
- int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec,
|
|
|
- getPaddingTop() + getPaddingBottom(), p.height);
|
|
|
+ int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec,
|
|
|
+ getPaddingTop() + getPaddingBottom(), p.height);
|
|
|
|
|
|
- view.measure(childWidthSpec, childHeightSpec);
|
|
|
- measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
|
|
|
- measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
|
|
|
- recycler.recycleView(view);
|
|
|
+ view.measure(childWidthSpec, childHeightSpec);
|
|
|
+ measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
|
|
|
+ measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
|
|
|
+ recycler.recycleView(view);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|