Skip to content

Commit

Permalink
修改吸顶抖动和ConsecutiveViewPager底部空白的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
teach committed Jul 24, 2020
1 parent 3bfe3ac commit cbf5e2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ public class ConsecutiveScrollerLayout extends ViewGroup implements ScrollingVie
// 临时保存吸顶的view,用于判断吸顶view是否改变了
private final List<View> mTempStickyViews = new ArrayList<>();

private int mOldScrollY = 0;

private final List<View> mViews = new ArrayList<>();
private int mNestedYOffset = 0;

Expand Down Expand Up @@ -747,6 +749,10 @@ protected int getChildDrawingOrder(int childCount, int drawingPosition) {
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
if (mOldScrollY != getScrollY()){
mOldScrollY = getScrollY();
resetSticky();
}

// 绘制边界阴影
if (mEdgeGlowTop != null) {
Expand Down Expand Up @@ -994,7 +1000,6 @@ private void scrollUp(int offset) {

if (oldScrollY != mOwnScrollY) {
scrollChange(mOwnScrollY, oldScrollY);
resetSticky();
}
}

Expand Down Expand Up @@ -1051,7 +1056,6 @@ private void scrollDown(int offset) {

if (oldScrollY != mOwnScrollY) {
scrollChange(mOwnScrollY, oldScrollY);
resetSticky();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ public ConsecutiveViewPager(@NonNull Context context, @Nullable AttributeSet att
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (isConsecutiveParent() && mAdjustHeight > 0) {
ConsecutiveScrollerLayout layout = (ConsecutiveScrollerLayout) getParent();
int parentHeight = layout.getMeasuredHeight();
int height = Math.min(parentHeight - mAdjustHeight, getDefaultSize(0, heightMeasureSpec));
int height = getDefaultSize(0, heightMeasureSpec) - mAdjustHeight;
super.onMeasure(widthMeasureSpec,
MeasureSpec.makeMeasureSpec(height, MeasureSpec.getMode(heightMeasureSpec)));
} else {
Expand Down

0 comments on commit cbf5e2d

Please sign in to comment.