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 56d1a607..d778a219 100644 --- a/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java +++ b/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java @@ -182,6 +182,14 @@ public class FlexboxLayoutManager extends RecyclerView.LayoutManager implements /** The reference to the parent of the RecyclerView */ private View mParent; + /** + * if mFillAllItemsForced == true fixes all issues with "not all items displayed when wrap_content" + * issues: #349 #336 #339 + */ + private Boolean mSetAllItemsForced = false; + + + /** * Indicates the position that the view position that the flex line which has the view having * this position needs to be recomputed before the next layout. @@ -312,6 +320,14 @@ public void setFlexWrap(@FlexWrap int flexWrap) { } } + public Boolean getmSetAllItemsForced() { + return mSetAllItemsForced; + } + + public void setmSetAllItemsForced(Boolean mSetAllItemsForced) { + this.mSetAllItemsForced = mSetAllItemsForced; + } + @JustifyContent @Override public int getJustifyContent() { @@ -874,7 +890,8 @@ private void updateFlexLines(int childCount) { // passed as 0 from the RecyclerView) // Set the upper limit as the height of the device in order to prevent computing all // items in the adapter - needsToFill = mLayoutState.mInfinite ? + // or set the mSetAllItemsForced to true to force all items to show + needsToFill = mSetAllItemsForced ? 999999999 : mLayoutState.mInfinite ? mContext.getResources().getDisplayMetrics().heightPixels : mLayoutState.mAvailable; } else { @@ -885,7 +902,8 @@ private void updateFlexLines(int childCount) { // passed as 0 from the RecyclerView) // Set the upper limit as the width of the device in order to prevent computing all // items in the adapter - needsToFill = mLayoutState.mInfinite ? + // or set the mSetAllItemsForced to true to force all items to show + needsToFill = mSetAllItemsForced ? 999999999 : mLayoutState.mInfinite ? mContext.getResources().getDisplayMetrics().widthPixels : mLayoutState.mAvailable; }