3

我的滑动动画有一个小刺激行为。

我制作了一个视频并将其发布在 youtube 上。我找不到任何可以从非root手机制作屏幕视频的应用程序,所以我不得不这样做:)

注意:仔细看第一个动画,从 00:07 开始你会注意到一个小闪光..这只是第一次发生,我触发了动画......

之后,在视频中,我又触发了几次动画,没有闪光,一切都运行得很顺利。

这是我使用的代码:

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;
    }

}

问题的根源似乎是什么?

我知道这是一件小事,但它很烦人,需要修复!

4

0 回答 0