Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the rectangle of the Drawable of ImageView on Android?

I want to get the rectangle object that will wrap the Drawable of ImageView instead of the rectangle that will wrap the ImageView. I will use that rectangle to draw some fancy rectangle around Drawable. How can I get that rectangle?

like image 938
ipman Avatar asked Jan 24 '12 13:01

ipman


1 Answers

    Rect rect = new Rect();
    ImageView iV = new ImageView();

    rect.left = iV.getLeft();
    rect.top = iV.getTop();
    rect.bottom = iV.getBottom();
    rect.right = iV.getRight();

Now you have your rectangle.

like image 108
SlowDeep Avatar answered Sep 18 '22 18:09

SlowDeep