Android Question Button - Corner Radius

Johan Schoeman

Expert
Licensed User
Longtime User
I am trying to understand the relationship between the width/height of a button (assuming it is a square) and the corner radius setting of a button. I would have thought that setting the corner radius to half the width (or height for that matter, assuming it is a square) will give one a perfect circle. But it seems not to be the case. See attached project:

1. Setting the corner radius to half of the width / height yields a square with rounded corners
2. Setting the corner radius to 80% of the width / height yields a "smaller" square with bigger rounder corners.
3. Setting the corner radius to 100% of the width/height yields a "perfect" circle.

So, what is the reference point where the corner radii are drawn from?
 

Attachments

  • RoundButton.zip
    12.2 KB · Views: 553

klaus

Expert
Licensed User
Longtime User
You don't set the radius to half the width / height !
In the DesignerScripts you use AutoScale and you define Button.Width = 20%x !
So in most cases the width will not be 100dip like defined in layout.
And of course 50dip for the radius is no more the half of the width !
If you comment the width and height definitions you get circle buttons.
I'm afraid that you can't set the radius to the half of the width in the Designer but you must do it the code.
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
If I comment out AutoScaleAll as well as the width/height lines in the designer script I get three small (but same sized) circles. Why does it yield 3 circles looking the same when the button corner radii are left at 50, 80, and 100 respectively? Should the "shape" of the buttons not be different?
 
Upvote 0
Top