I am trying to do an animation where the clip size changes and thus the size of an drawn bitmap changes, but I want it to look like an animation. Basically, what I did was in the views onDraw() method, i have made code that changes the clip size as necessary and every time it draws the bitmap, the image size is changed.
I am confused as to how to call the onDraw method repeatedly on the View with a certain pause in between…lets say 100ms
My current code just creates a runnable on the UI thread that does this. However, it fails miserably 🙁 I am not sure what to do.
final Handler handler = new Handler();
Runnable runnable = new Runnable() {
public void run() {
DrawnCircle hnd = ((DrawnCircle)AVE.MAIN.findViewById(R.id.drawnCircle1));
while(hnd.getSweep()<=360){
hnd.setSweep(hnd.getSweep()+1);
hnd.invalidate();
try {Thread.sleep(100);} catch (InterruptedException e) {}
}
}
};
handler.post(runnable);
thank you for your time and effort
I’m just learning animation myself, but how about using Android’s ValueAnimator class? If you’re trying to animate an integer value you could do something like this: