0

I have to make an app in which an image is loaded from the gallery and a rectangle can be drawn on the image to focus a specific part of the image. The rectangle is drawn dynamically and it can be re-sized and dragged. So i have made a custom view for my rectangle. Now i want to add this rectangle view on my image view. How is this adding of a custom view on a image view possible dynamically. I tried using frame layout but it didn't help.

4

1 回答 1

0

The ImageView is now ViewGroup so no View can be added to the ImageView. Instead you can draw directly on the ImageView itself by overriding the method onDraw(Canvas) of the ImageView.

An other possibility is to have your view with the rectangle over the image view and have a transparent background. To have two view over one another you can use the RelativeLayout Object.

于 2012-08-08T18:31:16.103 回答