Skip to content

Commit a84fda7

Browse files
committed
fix(android): add padding left to waterfall item layout
1 parent cfc0b59 commit a84fda7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

driver/js/examples/hippy-react-demo/src/components/WaterfallView/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ export default class ListExample extends React.Component {
318318
}
319319

320320
getWaterfallContentInset() {
321-
return { top: 0, left: 0, bottom: 0, right: 0 };
321+
return { top: 12, left: 12, bottom: 12, right: 12 };
322322
}
323323

324324
getItemStyle() {
@@ -376,6 +376,7 @@ export default class ListExample extends React.Component {
376376
columnSpacing={columnSpacing}
377377
interItemSpacing={interItemSpacing}
378378
numberOfItems={dataSource.length}
379+
contentInset={contentInset}
379380
preloadItemNumber={4}
380381
style={{ flex: 1 }}
381382
onScroll={this.onScroll}

renderer/native/android/src/main/java/androidx/recyclerview/widget/HippyStaggeredGridLayoutManager.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.view.View;
2020

2121
import android.view.ViewGroup;
22+
2223
import androidx.annotation.NonNull;
2324
import androidx.recyclerview.widget.RecyclerView.Adapter;
2425
import androidx.recyclerview.widget.RecyclerView.State;
@@ -65,15 +66,18 @@ public void layoutDecoratedWithMargins(@NonNull View child, int left, int top, i
6566
if (isFullSpan) {
6667
child.layout(left, top, right, bottom);
6768
} else {
68-
int lf = spanIndex * (lp.width + mItemDecoration.getColumnSpacing());
69-
int rt = (spanIndex + 1) * lp.width + spanIndex * mItemDecoration.getColumnSpacing();
69+
int lf = mRecyclerView.getPaddingLeft() + spanIndex * (lp.width
70+
+ mItemDecoration.getColumnSpacing());
71+
int rt = mRecyclerView.getPaddingLeft() + (spanIndex + 1) * lp.width
72+
+ spanIndex * mItemDecoration.getColumnSpacing();
7073
child.layout(lf, top, rt, bottom);
7174
}
7275
int size;
7376
if (child instanceof PullRefreshContainer) {
7477
size = getOrientation() == RecyclerView.VERTICAL ? bottom - top : right - left;
7578
} else {
76-
size = getOrientation() == RecyclerView.VERTICAL ? lp.height + mItemDecoration.getItemSpacing()
79+
size = getOrientation() == RecyclerView.VERTICAL ? lp.height
80+
+ mItemDecoration.getItemSpacing()
7781
: lp.width + mItemDecoration.getItemSpacing();
7882
}
7983
RenderNode childNode = RenderManager.getRenderNode(child);

0 commit comments

Comments
 (0)