android - Options for endlessly repeating function GUI calls while remaining responsive -
i've got animation perform consists of arrow heads aligned horizontally alpha values of arrows change achieve animation effect (i.e. first arrow has alpha 1.0, second value 1.0 etc.).
so if have function this:
void highlightfirstarrow() { marrow1.setalpha(1.0f); marrow2.setalpha(0.75f); marrow3.setalpha(0.50f); marrow4.setalpha(0.20f); }
then i'd want start, repeat numerous times, stop function such this:
void animatearrows() { highlightfirstarray(); pause; highlightsecondarray(); pause; etc. }
obviously lock gui thread if performed in example. options achieving desired animiation:
- run loop in separate thread - don't use loop, instead execute functions individually via timer - use built in specific android animation mechanisms. if appropriate? animatorset() scenario, or else
you shouldn't use loops or timers. there're lots of built in classes animate views. instance can use valueanimator
:
valueanimator.offloat(1f, 0.2f).setduration(1000).addupdatelistener(new valueanimator.animatorupdatelistener() { @override public void onanimationupdate(valueanimator animation) { float value = (float) animation.getanimatedvalue(); arrow1.setalpha(value); arrow2.setalpha(value); } });
Comments
Post a Comment