This episode covers different ways of animating multiple properties, and specifically covers the use of the lesser-known PropertyValuesHolder class.
YouTube: https://www.youtube.com/watch?v=WvCZcy3WGP4
Code: http://developer.android.com/shareables/devbytes/MultiPropertyAnimations.zip
2 comments:
I was wondering on how i could create custom-properties vor a custom-view, which i can then later animate with the ViewPortertyAnimator.
Something like "CustomView.MY_CUSTOM_PROPTERY"
I hope you can help me!
Thanks in advance ;)
And by the way: I really like your shows on DevBytes ;-)
Great stuff..so Im running an Object animator in a thread, with in a thread..
The first thread is a progress bar radial spinner, the second thread, with in the spinner thread, deals with animations, sounds, toast msg dependent on the result/status of the spinner.
I was getting a log cat error pointing to where I was calling the animation, something about "must call loop within a thread".
So I read upon looper threads and so on. Im a newbie at this so I just fiddled around with the code till I got it work, but I ended up not using loop. Im worried that my approach although it works, might leads to excessive memory usage/leaks. Any feedback would be appreciated.
final Runnable r = new Runnable() {
public void run() {
running = true;
ourSong = MediaPlayer.create(main.this, R.raw.youngblood);
ourSong2 = MediaPlayer.create(main.this, R.raw.rightsound2);
ourSong.start();
while(progress< my_percentage) {
pw_two.incrementProgress();
progress++;
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
running = false;
ourSong.stop();
/////MAYBE PUT THE ANIMATION STUFF HERE////
hd.post(new Runnable(){
public void run(){
PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1.3f);
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1.3f);
ObjectAnimator scaleAnimation = ObjectAnimator.ofPropertyValuesHolder(rb1, pvhX, pvhY);
scaleAnimation.setRepeatCount(1);
scaleAnimation.setRepeatMode(ValueAnimator.REVERSE);
//setupAnimation(rb1, scaleAnimation, R.animator.scale);
AnimatorSet setAnimation = new AnimatorSet();
setAnimation.play(scaleAnimation);
int displayed_score = Math.round(((float)my_percentage/360)*100);
if(displayed_score == 100){
//////add and play anim for this score////
ourSong3 = MediaPlayer.create(main.this, R.raw.e);
ourSong3.start();
//Toast.makeText(main.this,"this is 100 ",Toast.LENGTH_LONG).show();
}else if(displayed_score <= 90 && displayed_score >=80){
//////add and play anim for this score////
ourSong4 = MediaPlayer.create(main.this, R.raw.eight);
ourSong4.start();
rb1.setVisibility(View.VISIBLE);
scaleAnimation.start();
Toast.makeText(main.this,"this is less than 90 ",Toast.LENGTH_LONG).show();
}else if(displayed_score <= 80 && displayed_score >=70){
//////add and play anim for this score////
ourSong5 = MediaPlayer.create(main.this, R.raw.eighteen);
ourSong5.start();
//Toast.makeText(main.this,"this is less than 80 ",Toast.LENGTH_LONG).show();
}else if(displayed_score <= 70 && displayed_score >=60){
//////add and play anim for this score////
ourSong6 = MediaPlayer.create(main.this, R.raw.eleven);
ourSong6.start();
//Toast.makeText(main.this,"this is less than 70 THIS SHOULD SHOW on 67%",Toast.LENGTH_LONG).show();
}////////etc, etc/////
}
}
});
}
};
Post a Comment