[英]How to move right, left,top and bottom for zoom Image in android?
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.
我这里有4个按钮。 LeftButton,RightButton,TopButton and BottomButton.
LeftButton,RightButton,TopButton和BottomButton。 If I click 'LeftButton', Image should move left side.
如果单击“ LeftButton”,则图像应向左移动。 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 selectedPicture是我的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方法最适合您想要的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.