Android Question Button - Corner Radius

Discussion in 'Android Questions' started by Johan Schoeman, Mar 27, 2015.

  1. Johan Schoeman

    Johan Schoeman Expert Licensed 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?
     

    Attached Files:

  2. klaus

    klaus Expert Licensed 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.
     
  3. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Thanks for the explanation Klaus. Much appreciated!
     
  4. Johan Schoeman

    Johan Schoeman Expert Licensed 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?
     
  5. klaus

    klaus Expert Licensed User

    It seems that Android limits the corner radii to the half of the smallest side of a view.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice