Ideas:
1. Time-based display mapping. Such as: Given the degree, display arc, plus timing, you can have the effect of arc animation
2. Given timing.
A frame drawing for driving animations
Scenario One , based on Objectanimator. When the animation is working, it calls degree the corresponding set function (based on the emission call), i.e. Setdegree.
Objectanimator Ani=objectanimator.ofint (MyView, "degree", 0,300);
Ani.start ();
Note:1> after mixing, the default will be mixed setdegree, resulting in the function can not be found, so the mechanism after the mixture will be invalidated.
The workaround is to prevent this piece of code in 1.proguard (detailed method Baidu) 2. Usage Two
2>objectanimator is only supported after 3.0 and can be used with the Nineoldandroids library, with the same effect.
Scenario Two , still based on Objectanimator. But based on callbacks, such a method is not used to reflect, so the mixed time is still OK
Objectanimator Ani=objectanimator.ofint (MyView, New Prop (), 0,300);
Ani.start ();
Class Prop extends Property<view, integer> {public Prop () {//TODO auto-generated constructor Stubsuper (INTEGER.CLA SS, "KK");} @Overridepublic void Set (View object, Integer value) {//TODO auto-generated Method Stub ((MyView1) object). Setdegree ( value);} @Overridepublic Integer Get (View object) {//TODO auto-generated method Stubreturn null;}};
Programme III , the use of animation to provide timing.
Interpolatedtime is 0~1, which is the percentage of time.
Animation ani=new Animation () {@Overrideprotected void applytransformation (float interpolatedtime,transformation t) {/ /TODO auto-generated method Stubmyview.setdegree ((int) (INTERPOLATEDTIME*300F));}; Ani.setduration (n); Myview.startanimation (ANI);
//===========================================================================
Define your own view, setdegress can change the arc angle:
Private class MyView1 extends ImageView {public int degree = 0;public MyView1 (Context CT) {//TODO auto-generated Construc Tor Stubsuper (CT);} @Overrideprotected void OnDraw (canvas canvas) {//TODO auto-generated method Stubsuper.ondraw (canvas); Rect r = new rect (); Getlocalvisiblerect (R); Canvas.drawarc (new RECTF (R), 0, degree, true, PT);} public void Setdegree (int degree) {this.degree = Degree;invalidate ();}}
Effect:
"Android" itself defines OnDraw-based random animations (not just pan/rotate/zoom/alpha),!