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!