Skip to content

Commit

Permalink
fix(android): add padding left to waterfall item layout
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 committed Nov 4, 2024
1 parent cfc0b59 commit a84fda7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a84fda7

Please sign in to comment.