David
David

Reputation: 382

Android animation view: problems with scaling a view and then translating the view

When I attempt to increase the scale on a view (view.setScaleX(3)) and then animate it with view animation, I get the following problem:

(this screenshot is of a picture being set to three times its size and then being translated to the right) 1 2 3 4

what happens is that the view is increased to three times its size (which also increases the picture to three times its size), but when it attempts to translate the view, the scale is not kept and only a portion of the image of the same size of the original view is translated.

        ImageView iv = (ImageView) this.findViewById(R.id.testImage);
        iv.setScaleX(3);
        iv.setScaleY(3);

        TranslationAnimation ta = new TranslationAnimation(x,y,xf,yf);
        ta.setDuration(duration);
        ta.setFillAfter(true);
        ta.setFillEnabled(true);
        iv.startAnimation(ta);

any solution would be helpful

Upvotes: 0

Views: 214

Answers (1)

Itzik Samara
Itzik Samara

Reputation: 2288

Since setScaleX and setScaleY is kind of Animation my suggestion to you is use : AnimationSet

use ScaleAnimation with Fast duration ( >50) then TranslateAnimation.. this will do the Animations by order of insert and will fix your problem

Hope it Helps.

Upvotes: 1

Related Questions