bir*_*rdy 6 math android view drawable
假设我们有一个内半径为R2且外半径为R1的环.根据文件:
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
据我所知,这意味着innerRadiusRatio = 2*R1 / R2.
关于thicknessRatio有:
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.所以thicknessRatio = 2*R1 / (R1 - R2).
从这两个方程我们可以得到这个:thicknessRatio*(1-2/innerRadiusRatio)=2这意味着thicknessRatio和innerRadiusRatio之间存在联系.但是在GradientDrawable类文档中没有任何关于此连接的信息.并且似乎它们之间没有任何连接,因为我可以设置thicknessRatio和innerRadiusRatio,它不满足最后的等式.
请告诉我,在我考虑的地方我错了或者这个参数真正负责的是什么?
小智 38
我知道这已经很晚了,但它可能会帮助其他人寻找这个.
在文档中它说:
环的内半径表示为环的宽度比.
环的宽度不是环的半径,而是包含环的视图的宽度.我画这个是为了更简单的解释:

这是一个内部有环的视图方案.这些字母意思是:
我会补充说:
文档实际上描述了以下关系:
所以你可以实际计算半径.
您可以通过创建具有以下环的视图来证明这一点:
InnerRadiusRatio="4"
ThicknessRatio="4".
Run Code Online (Sandbox Code Playgroud)
这将创建一个与视图具有完全相同宽度的环.
注意:所有以前的公式都是在没有填充的情况下计算的.如果View上有填充,则应将每个W替换为(W-P).
比率是两个数字的比较,因此上述两个方程可以重写为
Ratio1 = InnerRadius :环宽度(其中Ratio1 = InnerRadiusRatio)
比率2 =厚度:环宽度(其中Ratio2 = ThicknessRatio)
意思是...
环宽=比率1 ×内半径=比率2 x厚度
自从您将其添加到等式中后出现" 2 ".所有等式中唯一的共同点是"环宽".用实数来试试也有帮助.