I am uploading an image in a screen. There i have Zoom-in an Zoom-out buttons. Already I have done Zoom-in and Zoom-out functions. Its working fine. what I need is, I want to drag and see the Image completely. But what happens now is, the image is not moving. I have 4 butons here. LeftButton,RightButton,TopButton and BottomButton. If I click 'LeftButton', Image should move left side. Similarly all the other functions. I am not really having idea, what I need to write inside the button clicks. Could anyone please guide me for this? Any help would be really appreciated..
Here is my code:
selectedPicture is my ImageLayout
case R.id.zoomInCtrl:
float x = selectedPicture.getScaleX();
float y = selectedPicture.getScaleY();
selectedPicture.setScaleX((float) (x + 0.5));
selectedPicture.setScaleY((float) (y + 0.5));
return true;
case R.id.zoomOutCtrl:
x = selectedPicture.getScaleX();
y = selectedPicture.getScaleY();
selectedPicture.setScaleX((float) (x - 0.5));
selectedPicture.setScaleY((float) (y - 0.5));
return true;
case R.id.leftCtrl:
/* code for move left */
return true;
case R.id.rightCtrl:
/* code for move right */
return true;
case R.id.topCtrl:
/* code for move top */
return true;
case R.id.bottomCtrl:
/* code for move bottom */
return true;
我认为View的setTranslationX和setTranslationY方法最适合您想要的内容。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.