Android环形Shape文档是否存在bug?innerRadiusRatio与thicknessRatio值异常
Android环形Shape默认属性值与文档不符问题
我绘制了一个环形Shape,代码如下:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" android:useLevel="false"> <solid android:color="@android:color/holo_blue_light" /> <size android:width="200dp" android:height="200dp" /> </shape>
我未指定innerRadiusRatio或thicknessRatio属性,根据Android官方文档,它们的默认值应分别为9和3。
但通过代码获取这些值时,结果却颠倒了:
val ring = ContextCompat.getDrawable(this, R.drawable.ring) as GradientDrawable Log.i(TAG, "thicknessRatio = ${ring.thicknessRatio}") Log.i(TAG, "innerRadiusRatio = ${ring.innerRadiusRatio}")
输出结果为:
thicknessRatio = 9.0
innerRadiusRatio = 3.0
我认为这可能是文档bug,但不确定是否有遗漏的细节。最终生成的环形明显厚度小于内半径:

内容的提问来源于stack exchange,提问作者bighugedev
相关产品推荐
相关产品推荐

