Is there anyway to get a Rect in which Bitmap is drawn on Android?

I am trying to subclass ImageView and draw something on Bitmap . However, I cannot find a way to get a Rect in which Bitmap is drawn. I can only get a Rect in which the ImageView drawn with the getDrawingRect(Rect) ImageView method. The following is an example of what I want to get:

enter image description here

I want Rect to be blue. Thanks in advance.

+7
source share
1 answer

This image will be drawn in ImageView based on the given attributes, for example, height, width, scaling factors, etc.

So, the getDrawingRect () method gives the entire ImageView area. If you change the stretchable inside the ImageView, the blue area may change depending on the image properties and image properties. But the yellow area will not change, since it is fixed and based only on ImageView, regardless of the image displayed.

I think there is no chance to get a Rect bitmap. I don’t think my answer is 100% correct, this is just a suggestion.

You can get information about the blue color area from the Drawing Cache . Try it once.

I hope this can help you.

+2
source

All Articles