Skip to content

Commit a31b0f3

Browse files
author
guangcheng.zhang
committed
Fix the measure bug
1 parent 4a380d9 commit a31b0f3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/src/main/java/net/lucode/hackware/magicindicatordemo/ext/navigator/ScaleCircleNavigator.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ private int measureWidth(int widthMeasureSpec) {
101101
break;
102102
case MeasureSpec.AT_MOST:
103103
case MeasureSpec.UNSPECIFIED:
104-
result = (mCircleCount - 1) * mMinRadius * 2 + mMaxRadius * 2 + (mCircleCount - 1) * mCircleSpacing + getPaddingLeft() + getPaddingRight();
104+
if (mCircleCount <= 0) {
105+
result = getPaddingLeft() + getPaddingRight();
106+
} else {
107+
result = (mCircleCount - 1) * mMinRadius * 2 + mMaxRadius * 2 + (mCircleCount - 1) * mCircleSpacing + getPaddingLeft() + getPaddingRight();
108+
}
105109
break;
106110
default:
107111
break;
@@ -209,7 +213,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
209213
@Override
210214
public void notifyDataSetChanged() {
211215
prepareCirclePoints();
212-
invalidate();
216+
requestLayout();
213217
}
214218

215219
@Override

0 commit comments

Comments
 (0)