Android custom Animation for an ArcShape

前端 未结 2 1017
萌比男神i
萌比男神i 2020-12-14 12:29

First let me explain my goal. I am trying to make an Animation that changes the properties of an ArcShape. An ArcShape\'s constructor

2条回答
  •  無奈伤痛
    2020-12-14 12:46

    I think you might be better off extending Drawable and override the draw() function to modify the sweep angle on each call and draw the corresponding arc. Draw is typically called every time the object is updated, which will mean that you'll have to make a new ArcShape every time it's drawn Animation is more for performing transformations on Views and other UI components.

    Something like:

    public class OpenPacman  
    {
    
    public OpenPacman(float startAngle, float sweepAngle) {  
        this.mStartAngle = startAngle;  
        this.mSweepAngle = sweepAngle;  
        this.wakaWaka = new ArcShape(this.startAngle, this.mSweepAngle);  
    } 
    
    public void draw(Canvas c){  
      //Do drawing stuff here with the canvas
    }
    
    //Your other functions for calculating angle, etc and making the ArcShape changes
    //Can call these from inside draw function so that when the view that contains your
    //object calls draw, it updates correctly.
    
    public float mStartAngle;  
    public float msweepAngle;  
    private ArcShape wakaWaka;  
    }
    

    Hope this gets you on the right track.

提交回复
热议问题