我想要获取可绘制对象的边界,但随后我使用 getBounds 或 copyBounds 方法。它们都返回 Rect(0, 0 - 0, 0)。
像这样的代码
Drawable marker = getResources().getDrawable(
R.drawable.tbar_single_pressed);
Rect copyRect = marker.copyBounds();
Rect getRect= marker.getBounds();
然后结果
复制矩形是 矩形(0, 0 - 0, 0)
getRect 也是 Rect(0, 0 - 0, 0)
为什么?标记不为空,我有剩余的 tbar_single_pressed....
thx
可绘制对象没有尺寸,除非它们已被绘制。如果您想获取传入图像的大小,您可以使用以下命令创建自己的矩形drawable.getIntrinsicWidth()
and drawable.getIntrinsicHeight()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)