GradientDrawable 类中的innerRadiusRatio 和thicknessRatio 之间存在什么样的联系?
假设我们有一个内半径为 R2 、外半径为 R1 的环。根据文档: 环的内半径以环宽度的比率表示。例如,如果innerRadiusRatio=9,则内半径等于环的宽度除以9
据我了解,这意味着 innerRadiusRatio = 2*R1 / R2
。
关于thicknessRatio有: 环的厚度,以环宽度的比率表示。例如,如果thicknessRatio=3,则厚度等于环的宽度除以3
。所以厚度比= 2*R1 / (R1 - R2) 。
从这两个方程我们可以得到这个:thicknessRatio*(1-2/innerRadiusRatio)=2
这意味着thicknessRatio和innerRadiusRatio之间存在联系。但是 GradientDrawable 类文档中没有任何关于此连接的信息。它们之间似乎没有任何联系,因为我可以设置 widthRatio 和 innerRadiusRatio ,但它不满足最后一个方程。
那么请告诉我我的考虑错在哪里,或者这个参数真正负责什么?
Let's supposed we've got a ring with inner radius R2 and outer radius R1. According documentation:Inner radius of the ring expressed as a ratio of the ring's width.For instance, if innerRadiusRatio=9, then the inner radius equals the ring's width divided by 9
As I understand this means that innerRadiusRatio = 2*R1 / R2
.
About thicknessRatio there is that:Thickness of the ring expressed as a ratio of the ring's width. For instance, if thicknessRatio=3, then the thickness equals the ring's width divided by 3
. So thicknessRatio = 2*R1 / (R1 - R2)
.
From this two equationі we can get this one: thicknessRatio*(1-2/innerRadiusRatio)=2
which means that there is a connection between thicknessRatio and innerRadiusRatio. But there is nothing about this connection in GradientDrawable class documentation. And it doesn't seem that there is any connections between them as I can set thicknessRatio and innerRadiusRatio which doesn't satisfying last equation.
So tell me please where I'm wrong in my consideration or what are this parameters really responsible for?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这已经很晚了,但它可能会帮助其他人寻找这个。
在文档中它说:
环的宽度不是环的半径,而是包含环的视图的宽度。我画这个是为了更简单的解释:
这是内部有环的视图的方案。这些字母的含义是:
我将添加:
该文档实际上描述了以下关系:
因此您可以实际计算半径。
您可以通过创建一个带有环的视图来证明这一点,该环具有:
这将创建一个与视图具有完全相同宽度的环。
注意:前面的所有公式都是在无填充的情况下计算的。如果视图上有填充,则应将每个 W 替换为 (W - P)。
I know this is pretty late, but it may help others looking for this.
In the documentation it says:
The ring's width is not the Radius of the ring, it is the width of the view containing the ring. I draw this for an easier explanation:
That's the scheme of a view with a ring inside. The letters mean:
And I will add:
The documentation actually describes the following relationship:
So you can actually calculate the Radius.
You can prove this by creating a view with a Ring that has:
This will create a ring that has exactly the same width as the view.
Note: All of the previous formulas are calculated with no padding. If there is padding on the View, you should replace every W with (W - P).
比率是两个数字的比较,因此上述两个方程可以重写为
Ratio1 = InnerRadius : 环宽度(其中 Ratio1 = InnerRadiusRatio)
Ratio2 = 厚度 : 环宽度 (其中 Ratio2 = ThicknessRatio)
这意味着...
环宽度 = Ratio1 x 内半径 = Ratio2 x
厚度自从您将其添加到方程中后,就出现了“2”。所有方程式中唯一的共同点是“环宽度”。用真实的数字进行尝试也有帮助。
Ratios are a comparison of two numbers, so the above two equations can be rewritten as
Ratio1 = InnerRadius : Ring Width (where Ratio1 = InnerRadiusRatio)
Ratio2 = Thickness : Ring Width (where Ratio2 = ThicknessRatio)
Which means...
Ring Width = Ratio1 x Inner Radius = Ratio2 x Thickness
The "2" appeared since you added it into your equation. The only common denominator in all equation is "Ring Width". Trying it out with real numbers helps too.