Skip to content

Commit

Permalink
Merge pull request #12 from jacobozamora/master
Browse files Browse the repository at this point in the history
Fix problems when layoutparams are match_parent
  • Loading branch information
pkleczko authored Oct 27, 2016
2 parents 6979550 + 51305e7 commit 4ebefe3
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,19 @@ else if (mStrokeCap.equals("ROUND"))
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
float paddingLeft = getPaddingLeft();
float paddingRight= getPaddingRight();
float paddingTop = getPaddingTop();
float paddingBottom = getPaddingBottom();
float width = getWidth() - (paddingLeft+paddingRight);
float height = getHeight() - (paddingTop+paddingBottom);
float radius = (width > height ? width/2 : height/2);

float rectLeft = width/2 - radius + paddingLeft;
float rectTop = height/2 - radius + paddingTop;
float rectRight = width/2 - radius + paddingLeft + width;
float rectBottom = height/2 - radius + paddingTop + height;
float padding = getStrokeWidth();
float size = getWidth()<getHeight() ? getWidth() : getHeight();
float width = size - (2*padding);
float height = size - (2*padding);
// float radius = (width > height ? width/2 : height/2);
float radius = (width < height ? width/2 : height/2);



float rectLeft = (getWidth() - (2*padding))/2 - radius + padding;
float rectTop = (getHeight() - (2*padding))/2 - radius + padding;
float rectRight = (getWidth() - (2*padding))/2 - radius + padding + width;
float rectBottom = (getHeight() - (2*padding))/2 - radius + padding + height;

mRect.set(rectLeft, rectTop, rectRight, rectBottom);

Expand Down

0 comments on commit 4ebefe3

Please sign in to comment.