Skip to content Skip to sidebar Skip to footer

Drag Imageview Inside A Webview

:) I'm adding an ImageView inside a WebView like this : void addImv(int in) { imageView.setId(imageID); webComp.addView(imageView); Bitmap bitmap; File sd

Solution 1:

This worked:

OnTouchListenerlistenTouch=newOnTouchListener()

{

public boolean onTouch(View v, MotionEvent event)
{   
    imageView.offsetLeftAndRight((int)event.getX()-imageView.getWidth());
    imageView.offsetTopAndBottom((int)event.getY()-imageView.getHeight());
    webComp.invalidate();
    returntrue;
}

};

Solution 2:

Use AbsoluteLayout.LayoutParams setting the correct X and Y co-ordinate or you can also use LinearLayout.LayoutParams OR RelativeLayout.LayoutParams for the purpose.

On how to use:

webComp.addView(imageView, <your paramsobject>);

Post a Comment for "Drag Imageview Inside A Webview"