diff --git a/driver/js/examples/hippy-react-demo/src/components/WaterfallView/index.jsx b/driver/js/examples/hippy-react-demo/src/components/WaterfallView/index.jsx index fba0512584b..f11147966fe 100644 --- a/driver/js/examples/hippy-react-demo/src/components/WaterfallView/index.jsx +++ b/driver/js/examples/hippy-react-demo/src/components/WaterfallView/index.jsx @@ -318,7 +318,7 @@ export default class ListExample extends React.Component { } getWaterfallContentInset() { - return { top: 0, left: 0, bottom: 0, right: 0 }; + return { top: 12, left: 12, bottom: 12, right: 12 }; } getItemStyle() { @@ -376,6 +376,7 @@ export default class ListExample extends React.Component { columnSpacing={columnSpacing} interItemSpacing={interItemSpacing} numberOfItems={dataSource.length} + contentInset={contentInset} preloadItemNumber={4} style={{ flex: 1 }} onScroll={this.onScroll} diff --git a/renderer/native/android/src/main/java/androidx/recyclerview/widget/HippyStaggeredGridLayoutManager.java b/renderer/native/android/src/main/java/androidx/recyclerview/widget/HippyStaggeredGridLayoutManager.java index 93ce23033e3..5532819fed2 100644 --- a/renderer/native/android/src/main/java/androidx/recyclerview/widget/HippyStaggeredGridLayoutManager.java +++ b/renderer/native/android/src/main/java/androidx/recyclerview/widget/HippyStaggeredGridLayoutManager.java @@ -19,6 +19,7 @@ import android.view.View; import android.view.ViewGroup; + import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView.Adapter; import androidx.recyclerview.widget.RecyclerView.State; @@ -65,15 +66,18 @@ public void layoutDecoratedWithMargins(@NonNull View child, int left, int top, i if (isFullSpan) { child.layout(left, top, right, bottom); } else { - int lf = spanIndex * (lp.width + mItemDecoration.getColumnSpacing()); - int rt = (spanIndex + 1) * lp.width + spanIndex * mItemDecoration.getColumnSpacing(); + int lf = mRecyclerView.getPaddingLeft() + spanIndex * (lp.width + + mItemDecoration.getColumnSpacing()); + int rt = mRecyclerView.getPaddingLeft() + (spanIndex + 1) * lp.width + + spanIndex * mItemDecoration.getColumnSpacing(); child.layout(lf, top, rt, bottom); } int size; if (child instanceof PullRefreshContainer) { size = getOrientation() == RecyclerView.VERTICAL ? bottom - top : right - left; } else { - size = getOrientation() == RecyclerView.VERTICAL ? lp.height + mItemDecoration.getItemSpacing() + size = getOrientation() == RecyclerView.VERTICAL ? lp.height + + mItemDecoration.getItemSpacing() : lp.width + mItemDecoration.getItemSpacing(); } RenderNode childNode = RenderManager.getRenderNode(child);