jeudi 14 mai 2015

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. 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;

Aucun commentaire:

Enregistrer un commentaire