在Canvas中,用RectF画一个矩形,需要将top和left设置为dp还是px?
Integer padding = 10;
Integer width = 100; // It is dp or px?
Integer height = 50;
RectF position = new RectF();
position.top = 0 + padding;
position.bottom = position.top + height;
position.left = 0 + padding;
position.right = position.left + width;
http://developer.android.com/intl/es/reference/android/graphics/RectF.html http://developer.android.com/intl/es/reference/android/graphics/RectF.html它不指示值是否以 px 或 dp 表示。
正如已经指出的,Canvas 和 RectF 使用 px 而不是 dp。
至于文档,Canvas 的文档
(http://developer.android.com/intl/es/reference/android/graphics/Canvas.html http://developer.android.com/intl/es/reference/android/graphics/Canvas.html)
而 RectF 只提到像素。
由于没有明确指出它们是 dp 并且这两个类都是直接从 java.lang.Object 派生的,所以只能得出结论,它一定是“正常”像素。
如果由于某种原因,您需要从 dp 转换为 px,反之亦然,请查看此文档:http://developer.android.com/intl/es/guide/practices/screens_support.html http://developer.android.com/intl/es/guide/practices/screens_support.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)