【发布时间】:2016-06-29 19:48:13
【问题描述】:
我正在跟踪一个问题,为什么 Rect.intersects 函数在我的 Android 应用程序中不起作用,并发现我的一个矩形的宽度和高度不正确。
ImageView tt = (ImageView)findViewById(R.id.tt);
Rect newInRect = new Rect(421, tt.getTop(), tt.getRight(), tt.getBottom());
Log.d("Size comparison", String.format("getRight %d, getLeft: %d | Width: %d, Height: %d", tt.getRight(), tt.getLeft(), newInRect.width(), newInRect.height()));
输出为:“大小比较:getRight 296,getLeft:144 | 宽度:-124,高度:152”
getRight() 和 getBottom() 函数不代表宽度和高度吗? 为什么它们返回不同的值?哪一个是正确的? 我的意图是使 Rect 与名为 tt 的 ImageView 大小完全相同,但 X 坐标不同。我该怎么做?
【问题讨论】: