Created
June 21, 2019 09:59
-
-
Save mohamad-shafaee/f6c934dd5045d73d3453ca36e0576890 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.msh_n.myp.customview1; | |
public class MainActivity extends AppCompatActivity { | |
Button button; | |
float newAngle; | |
float oldAngle; | |
ObjectAnimator animatorX; | |
ValueAnimator.AnimatorUpdateListener mListener; | |
PieView pieView; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
button = (Button) findViewById(R.id.button1); | |
pieView = (PieView) findViewById(R.id.pieView2); | |
animatorX = ObjectAnimator.ofFloat(pieView, "angle", 0, 180); | |
animatorX.setDuration(4000); | |
mListener = new ValueAnimator.AnimatorUpdateListener() { | |
@Override | |
public void onAnimationUpdate(ValueAnimator valueAnimator) { | |
pieView.invalidate(); | |
} | |
}; | |
animatorX.addUpdateListener(mListener); | |
button.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
animatorX.start(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment