From c60f9c9f95e4a4157afda642d70b488f20a9feaf Mon Sep 17 00:00:00 2001 From: ly85206559 Date: Wed, 2 Aug 2017 15:45:05 +0800 Subject: [PATCH 1/2] Fix issue #336 This is not the best sulotion,but now it can resolve the problem. This problem is not so easy. Calculate the decoration is conflict with the method isWrapRequired,and i can not reuse the view for both calculate the decoraion and isWrapRequired. So this solution is just for get the decoration with the view,and the capability maybe not so good.But it certenly solve the problem. --- .../java/com/google/android/flexbox/FlexboxLayoutManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java b/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java index 3d931cee..12fb35c4 100644 --- a/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java +++ b/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java @@ -368,8 +368,10 @@ public List getFlexLines() { @Override public int getDecorationLengthMainAxis(View view, int index, int indexInFlexLine) { + View v = mRecycler.getViewForPosition(index); + calculateItemDecorationsForChild(v, TEMP_RECT); if (isMainAxisDirectionHorizontal()) { - return getLeftDecorationWidth(view) + getRightDecorationWidth(view); + return getLeftDecorationWidth(v) + getRightDecorationWidth(v); } else { return getTopDecorationHeight(view) + getBottomDecorationHeight(view); } From a4584a790d2b4746486b96cef86b0d73b4323ad3 Mon Sep 17 00:00:00 2001 From: Ban Date: Tue, 8 Aug 2017 14:50:12 +0800 Subject: [PATCH 2/2] Put code into if conditional statement. --- .../com/google/android/flexbox/FlexboxLayoutManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java b/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java index 12fb35c4..ed25e103 100644 --- a/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java +++ b/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java @@ -368,10 +368,10 @@ public List getFlexLines() { @Override public int getDecorationLengthMainAxis(View view, int index, int indexInFlexLine) { - View v = mRecycler.getViewForPosition(index); - calculateItemDecorationsForChild(v, TEMP_RECT); if (isMainAxisDirectionHorizontal()) { - return getLeftDecorationWidth(v) + getRightDecorationWidth(v); + view = mRecycler.getViewForPosition(index); + calculateItemDecorationsForChild(view, TEMP_RECT); + return getLeftDecorationWidth(view) + getRightDecorationWidth(view); } else { return getTopDecorationHeight(view) + getBottomDecorationHeight(view); }