4

I want to crop my image which is being displayed on an ImageView. How I want to go about it is that I want a re-sizable rectangle to be displayed on the image. That rectangle will have moveable corners (which I can drag around with touch) to increase/decrease its size. The image below illustrates a demo of something I would like to develop.

Screenshot

guipivoto
  • 18,327
  • 9
  • 60
  • 75
Nagendra
  • 193
  • 4
  • 14

1 Answers1

1

As your question is very vague here is some general approach to solve this by creating an own View. I would suggest you extend the Androids ImageView with your own class.

Within this class you can use the

public void draw(Canvas canvas)

method to draw additional elements like a rectangular or circles for the corners (don't forget to call super.draw so that the image is also drawn.

Furthermore, you have to intercept the UI events on that view to decide if a corner was moved by the user. See http://developer.android.com/guide/topics/ui/ui-events.html for more details on that.

Within your layout you can add this view just by an XML tag with your package and view class as tag name. e.g.:

<com.example.MyCustomView android:layout_height="fill_parent" android:layout_width="fill_parent" android:src="@drawable/myImage"/>
senola
  • 782
  • 4
  • 12
  • I want to draw an image as a background then draw a rectangle on the image, we know the rectangle have four fixed points, when i drag one of these the rectangle can scale – Nagendra Oct 20 '11 at 05:52