Sandah Aung
Sandah Aung

Reputation: 6188

Image animation on Android

I want an image on an Android screen to appear smaller when the user touches down on it and to get back to its original size when the user releases it. I want the animation to be smooth and I also want to utilize minimum computing resources. How can this best be implemented?

Upvotes: 4

Views: 123

Answers (2)

Attaullah
Attaullah

Reputation: 4021

try this code

          @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {

                case MotionEvent.ACTION_DOWN:
                   // do something here when touch
                break;

                case MotionEvent.ACTION_UP:
                   // do something here when touch release     
                break;
                }

                return true;
            }

for animation try this animation-source_code

Upvotes: 4

Manish
Manish

Reputation: 1215

You can probably use the ScaleAnimation with the onTouch event of the view. In onTouch when you get the ACTION_DOWN you can start the ScaleAnimation and when you get ACTION_UP just revert the animation.

Upvotes: 3

Related Questions