Skip to content Skip to sidebar Skip to footer

Select Content Inside Imageview - Android

I have an Activity containing an ImageView and I'd like to allow the User to select part of it's content with the touch (or mouse click) capabilities. I'd like to write a procedure

Solution 1:

I would subclass ImageView then you can capture the touch events by overriding onTouchEvent(...)

When you get to the onDraw(...) method you can call super to draw the image as normal, then add your own code to draw a highlight over the top.

EDIT

Well instead of using ImageView you can extend it and write your own class, all this class has to do is override onTouchEvent(...) so you know when the view is being touched and can save the location on screen of the touch events. Next you edit the drawing methods:

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas); // So the image you want is drawn as normalmyMethodForDrawingAFancyHighlight(Canvas canvas); // add your special effects on top of the image
}

Post a Comment for "Select Content Inside Imageview - Android"