Skip to content

Commit

Permalink
修复了只有一个item上下边距错误的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarvis-Lau committed Sep 30, 2018
1 parent 7a12fef commit e9e782e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.recyclerView);
ArrayList<Entity> entities = new ArrayList<>();
for (int i = 0; i < 23; i++) {
for (int i = 0; i < 1; i++) {
entities.add(new Entity("text" + i, "2018-07-" + i));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ private void getLinearLayoutItemOffsetsVertical(Rect outRect, boolean reverseLay
if (!reverseLayout) {
if (childAdapterPosition == 0) {
outRect.set(0, recyclerMarginTopPxValue, 0, 0);
if (parent.getAdapter().getItemCount() == 1) {
outRect.set(0, recyclerMarginBottomPxValue, 0, recyclerMarginTopPxValue);
if (parent.getAdapter().getItemCount() == 1 && isMarginBottomWhenNotMatch) {
outRect.set(0, recyclerMarginTopPxValue, 0, recyclerMarginBottomPxValue);
}
} else if (childAdapterPosition == parent.getAdapter().getItemCount() - 1) {
//根据firstCompleteVisibleItem下标,判断item是否超出屏幕(是否能滑动)
Expand Down

0 comments on commit e9e782e

Please sign in to comment.