I keep getting top, bottom, left, right = 0. I guess I am doing this wrong, what is the correct way? TIA
in onCreate()
ImageView trash = (ImageView) findViewById(R.id.dropTarget_trash);
trash.setOnTouchListener(this);
Rect trashHit = new Rect();
trash.getHitRect(trashHit);
Log.d(TAG,"Trash left:" + trashHit.left + " right: " + trashHit.right + " top: " + trashHit.top + " bottom: " + trashHit.bottom);
As the hit rect is in the parent coordinate space, the parent first needs to layout its children which it hasn’t done yet during
onCreate(). Take a look at the solution here for an example of running inpost(). If you have a custom view,getHitRect()withinonDraw()will give you the correct dimensions too.