Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMalcolm Mutambanengwe
4,205 Pointscustom animation
I'm doing exactly as instructed in the video. Am I missing something? Steve Hunter
public class AlphaScale extends Visibility {
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
return createAlphaScaleAnimator(view, 0, 1);
}
@Override
public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
return createAlphaScaleAnimator(view, 1, 0);
}
private Animator createAlphaScaleAnimator(View view, float fromScale, float toScale, float fromAlpha, float toAlpha) {
AnimatorSet set = new AnimatorSet();
ObjectAnimator x = ObjectAnimator.ofFloat(view, View.SCALE_X, fromScale, toScale);
ObjectAnimator y = ObjectAnimator.ofFloat(view, View.SCALE_Y, fromScale, toScale);
ObjectAnimator alpha = ObjectAnimator.ofFloat(view, View.ALPHA, fromAlpha, toAlpha);
set.playTogether(x, y, alpha);
return set;
}
}
2 Answers
Steve Hunter
57,712 PointsHi Mal,
Have a look at what the createAlphaScaleAnimator
method needs to receive as arguments. It wants a View
and four floats. Pass in those; the onAppear
goes from zero to 1 for both the scale
and alpha
so that looks like:
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
return createAlphaScaleAnimator(view, 0, 1, 0, 1); // 5 arguments
}
I hope that helps,
Steve.
Malcolm Mutambanengwe
4,205 PointsOk I see. A thousand thanks ;)
Emmanuel Chiraerae
6,029 PointsEmmanuel Chiraerae
6,029 Pointsthank you was also stuck here