This should be fairly simple, but it is turning out to be more complicated than I thought. How can I apply a ScaleAnimation to a view and get it to stay for the entire duration of a finger press? In other words, while he finger is down shrink the view until the finger is removed, then return it to its original size?
This is what I have tried:
public void onTouch(View v, MotionEvent event)
{
switch(event.getAction())
{
case MotionEvent.ACTION_DOWN
{
v.setAnimation(shrinkAnim);
}
case MotionEvent.ACTION_UP
{
v.setAnimation(growAnim);
}
}
}
If I apply setFillEnabled(true) and setFillAfter(true) then the shrink stays indefinitely. If I don’t use it it shrinks for a second then goes back to normal. Thanks ahead of time
It’s a bit unclear what you have and haven’t tried in what combination, so here’s an example that works:
The animations should be defined once and reused, with their
setFillAfter(true)parameter set; this makes the drawing stick in the final position. When you apply the animations to the view usestartAnimation(),setAnimation()is designed for animations that manage their own start times.Hope that Helps!