What is the relationship between innerRadiusRatio and Ratio thickness of the GradientDrawable class?

Suppose we have a ring with an inner radius R2 and an outer radius R1. According to the documentation: Inner radius of the ring expressed as a ratio of the ring width.For instance, if innerRadiusRatio=9, then the inner radius equals the ring width divided by 9 As I understand it, this means that innerRadiusRatio = 2*R1 / R2 .

About the thickness of the Ratio is this: Thickness of the ring expressed as a ratio of the ring width. For instance, if thicknessRatio=3, then the thickness equals the ring width divided by 3 Thickness of the ring expressed as a ratio of the ring width. For instance, if thicknessRatio=3, then the thickness equals the ring width divided by 3 . So thicknessRatio = 2*R1 / (R1 - R2) .

From this two equations we can get this: thicknessRatio*(1-2/innerRadiusRatio)=2 , which means that there is a relationship between the thickness of Ratio and innerRadiusRatio. But there is no class documentation in this GradientDrawable about this connection. And it does not seem that there are any connections between them, since I can set the thickness of Ratio and innerRadiusRatio, which does not satisfy the last equation.

So tell me, please, where am I mistaken in my considerations or for what these parameters are really responsible for?

+6
source share
2 answers

Relations is a comparison of two numbers, so the above two equations can be rewritten as

Ratio1 = InnerRadius : Width of the ring (where Ratio1 = InnerRadiusRatio)

Ratio2 = Thickness : Width of the ring (where Ratio2 = ThicknessRatio)

What does it mean ...

Ring Width = Ratio1 x Inner Radius = Ratio2 x Thickness

" 2 " has appeared since you added it to your equation. The only common denominator in the whole equation is โ€œRing Widthโ€. Trying to cope with real numbers also helps.

+3
source

I know this is pretty late, but it can help others who are looking for it.

The documentation says:

The inner radius of the ring is expressed as the ratio of the width of the ring .

The width of the ring is not the radius of the ring, it is the width of the view containing the ring. I am drawing this for an easier explanation:

enter image description here

That is a vision scheme with a ring inside. The letters mean:

  • W: Width
  • P: Padding
  • Th: Thickness
  • Ir: Inner radius.

And I will add:

  • R: Radius.
  • IRR: InnerRadiusRatio.
  • THR: ThicknesRatio.

The documentation actually describes the following relationship:

  • Ir = W / IRR
  • Th = W / THR

So you can calculate the radius.

  • R = Ir + Th = W (1 / IRR + 1 / THR).

You can prove this by creating a view with a ring that has:

 InnerRadiusRatio="4" ThicknessRatio="4". 

This will create a ring that is the same width as the view.

Note: All previous formulas are calculated using without filling . If the view is indented, you should replace each W (W - P).

+26
source

Source: https://habr.com/ru/post/900060/


All Articles