-2

I'm trying to make an animation on a layout that has been previously rotated using RotateAnimation. The animation i want to do are fadeIn and FadeOut depending of the situation

aLayout = (LinearLayout) _context.findViewById(R.layout.layoutId);

    AlphaAnimation fadeIn = new AlphaAnimation(0, 1.0f);
    AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0);
    fadeIn.setDuration(500);
    fadeOut.setDuration(500);
    fadeIn.setFillAfter(true);
    fadeOut.setFillAfter(true);

Depending of the situation i apply :

aLayout.startAnimation(fadeIn);

or

aLayout.startAnimation(fadeOut);

I've check and the animations aren't trying to start at the same time. The behaviour is that my layout is partially fadeIn.

Instead of having 'invisible part' and then 'visible part'

i only got part of the layout 'invisible part' to 'in le rt'.

It seems totally random that's why i'm asking you in case you have any idea of where it can come from. Before the rotation this alpha stuff works well but once i do it i start having this unexpected behaviour

I'm working from 2.2 to 4.1 Any help would be appreciated. Thanks

Edit : Can't figure this out. Anyone ?

ophilbert
  • 199
  • 1
  • 9

2 Answers2

0

I use a fadeout animation using this:

public void fadeout(final View view) {
    // Start Fade Animation
    Animation fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setStartOffset(1000);
    fadeOut.setDuration(1000);
    AnimationSet animation = new AnimationSet(false);
    animation.addAnimation(fadeOut);
    view.startAnimation(animation);
}

and I call it in the onCreate after setting the Content view of the activity that I want to fade out after grabbing the layout root:

    View layoutRoot = findViewById(R.id.splashscreen);
    fadeout(layoutRoot);

As for the rotation part you can call the animation in the onConfigurationChanged

Nick
  • 9,285
  • 33
  • 104
  • 147
  • I must perform the animation very often, i can't do it in onCreate. I just want to know what can cause animation to blink this way (only portion of the layout are shown. The other part appear when animation ends) – ophilbert Aug 28 '12 at 12:43
0

Seems it's a bug on android. Couldn't figure how to solve it. Anyway, i found another way to do this. Instead of making the Layout rotating i rotate only the UIElement i needed to be rotate and create the element i want to animate twice. One for the vertical position the other for the horizontal one.

This is the only way i found

ophilbert
  • 199
  • 1
  • 9