Wednesday, 15 January 2014

android - Animation only starts after speech recognition has completed -



android - Animation only starts after speech recognition has completed -

i'm writing app uses android's speech recognition.

in recognitionlistener have this:

@override @targetapi(build.version_codes.honeycomb) public void onrmschanged(float rmsdb) { if(mspeakbuttonborder == null) mspeakbuttonborder = (imageview) findviewbyid(r.id.speakbuttonborder); // should go on growing in size each time onrmschanged called. animation animation = new scaleanimation(mspeakbuttonborder.getscalex(), mspeakbuttonborder.getscalex() + 0.1f, mspeakbuttonborder.getscaley(), mspeakbuttonborder.getscaley() + 0.1f); animation.setduration(1000); animation.setfillafter(true); mspeakbuttonborder.startanimation(animation); }

why animation start after recognition has returned result?

onrmschanged() maintain getting called while speech recognition going on. since you've set fillafter true , duration of animation 1000 ms.

so you're infact, starting new animation in every phone call onrmschanged() (called every few ms or more frequently) before animation finishes. problem transformations applied not apply view, transform way it's drawn.

i believe animation still getting applied. transformation min notice, 1 because of duration beingness little , because target scale factor small.

so when utilize supposedly current scalex next time, results in same value original (which 1.0).

you may utilize objectanimator animate, applies transformations view or calculate relative input scale values , feed scaleanimation.

android android-animation

No comments:

Post a Comment