Android Question Measure biggest label size on a panel with rounded "corners" (GradientDrawable)

Discussion in 'Android Questions' started by KMatle, Sep 22, 2017.

  1. KMatle

    KMatle Expert Licensed User

    Maybe there's an answer, but I'm unable to find it... I have a panel (with "rounded corners" via GradientDrawable). On the panel there's a label. What I need is to "calculate" if the label fits into the panel without touching the rounded corners (the label is a square and the corners may be drawn outside the rounded panel's "corners") . More exactly: Calculate the biggest possible size of the label which fits.
  2. klaus

    klaus Expert Licensed User

    Something like this:
    CornerRadius = GradientDrawable.CornerRadius
    MaxLabelWidth = 
    Panel.Width - 2 * CornerRadius
    MaxLabelHeight = 
    Panel.Height - 2 * CornerRadius
    KMatle likes this.
  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