Zoom imageView
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; } }
相关推荐
wuzaiwuzai 2020-04-21
Arduino机器人 2020-04-13
天堂里的雪 2019-11-15
qinbiao00 2014-12-10
yxy 2014-12-10
csscode 2019-06-29
chongxiaocheng 2015-01-24
风萧萧梦潇 2014-08-01
Phoebe的学习天地 2013-11-15
hermanncain 2019-06-21
jianqi 2019-06-21
小白的黑科技 2014-10-15
maple00 2011-03-30
每天积累一点点 2011-03-10
AndroidGA 2011-09-07
qinxu 2010-10-25
Techzero 2017-08-29