3

I have a small irritating behaviour of my sliding Animation.

I made a video and posted it on youtube. I could'nt find any app that can make a screen video from non-rooted phone, so I hade to do it this way :)

NOTE: look closely at the first animation, starting from 00:07 You will notice a small flash..that happens only for the first time, I trigger animation...

Afterwards, in the video, I trigger animation few more times, and there is no flash and everything runs smoothly.

Here is the code I use:

private void slideDown(){

    // Here I calculate the height of a header and the ListView (That is not populated in the video, therefore - white and empty), as it will be different for different screen sizes
    float headerHeight = header.getHeight();
    float topicNameHeight = topHeader.getHeight()+1;
    float totalHeight = headerHeight+topicNameHeight;
    float listSize = listView.getHeight();

    int theSizeIWant = (int) (listSize+totalHeight);


    //slide down
    if (counter==0){
        listView.setPivotY(0);
        ObjectAnimator slideAnimation = ObjectAnimator.ofFloat(listView, "y",topicNameHeight);
        ObjectAnimator rotateAnimation = ObjectAnimator.ofFloat(btn_slider, "rotation",0f,180f);
        listView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, theSizeIWant));

        rotateAnimation.setDuration(800);
        slideAnimation.setDuration(800);

        slideAnimation.start();
        rotateAnimation.start();
        counter=1;
    }
    //slide up
    else{
        ObjectAnimator slideAnimation = ObjectAnimator.ofFloat(listView, "y",totalHeight);
        ObjectAnimator rotateAnimation = ObjectAnimator.ofFloat(btn_slider, "rotation",180f,360f);
        listView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int)listSize));

        rotateAnimation.setDuration(800);
        slideAnimation.setDuration(800);

        slideAnimation.start();
        rotateAnimation.start();

        counter=0;
    }

}

What seems to be the source of the problem?

I know it's a small thing, but it is majorly irritating, and needs to be fixed!

SteBra
  • 4,188
  • 6
  • 37
  • 68
  • 1
    +1 for "posted it on youtube" :) – Blaze Tama Oct 30 '14 at 09:50
  • A Jedi gotta do what a Jedi gotta do :) – SteBra Oct 30 '14 at 09:51
  • 1
    Have you seen this : http://stackoverflow.com/questions/9387711/android-animation-flicker – Blaze Tama Oct 30 '14 at 09:54
  • 1
    Try to go to "Developer options" and enable "Force GPU rendering" and "Disable HW overlays" and see what happens. That way you may find what is causing that flash. – mykolaj Oct 30 '14 at 09:55
  • @av_lee No, unfortunately, same thing happens :( – SteBra Oct 30 '14 at 09:58
  • tried using ViewPropertyAnimator? – pskink Oct 30 '14 at 10:02
  • @beworker Man, now it's even worse. Instead of sliding up, now it flickers and slides from the top, somehow :) But also only on the first animation trigger...after that, it works as intended. Really strange – SteBra Oct 30 '14 at 10:06
  • @beworker Also, i dont want to animate moving of a view, but the change in the view's height – SteBra Oct 30 '14 at 10:07
  • @pskink I might have used it, however I realy want to find a solution to using ObjectAnimator. Especially because this flickr happens only in this Activity. I have the same code in previous activity, and it works perfectly – SteBra Oct 30 '14 at 10:09
  • so at least use AnimatorSet, its optimised to play several Animators... – pskink Oct 30 '14 at 10:17
  • @pskink Ok, point taken and you're right. But even if I comment out btn rotation animation, and eleave only "y" animation, there is still a flicker :( – SteBra Oct 30 '14 at 10:21
  • that is worse ... ;( – pskink Oct 30 '14 at 10:24

0 Answers0