public class Zoom extends View {
private Drawable image;
private int zoomControler=200;
public Zoom(Context context)
{
super(context);
image=context.getResources().getDrawable(R.drawable.gallery_photo_1);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//here u can control the width and height of the images........ this line is very important
image.setBounds((getWidth()/2)-zoomControler, (getHeight()/2)-zoomControler, (getWidth()/2)+zoomControler, (getHeight()/2)+zoomControler);
image.draw(canvas);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_DPAD_UP)// zoom in
zoomControler+=10;
if(keyCode==KeyEvent.KEYCODE_DPAD_DOWN) // zoom out
zoomControler-=10;
if(zoomControler<10)
zoomControler=10;
invalidate();
return true;
}
}
If any body knows the other way they can post here it should be helpful for others to develop.....
Hi,
ReplyDeleteThanks for the tutorial but i have read a image in sdcard then how i can zoom with that images.
thanks
Hi,
ReplyDeleteThanks for this post.I have an image read from sdcard then how to create zoom in that images.
Pls reply for me.
Thanks.
Hi,
ReplyDeleteThis post is very useful for me but i have read images from sdcard,then how can i zooming that images.pls help me.
thanks.
i need full coding....i am new for android application so if u post full coding. its very useful to me.....
ReplyDeleteimage=context.getResources().getDrawable(R.drawable.kinglogo);
ReplyDeleteI m getting error on this line. I have an image called kinglogo for which i want to add zooming level.
I want to create a separate package for the above code. plz can u help me how to have access to this code from some other package I m new to android.. It would be helpful.. thank u in advance..
nice
ReplyDeleteThanks..
ReplyDeleteThanks . . .
ReplyDeletetanks...very good!
ReplyDelete