Skip to content

Instantly share code, notes, and snippets.

@mohamad-shafaee
Created June 21, 2019 09:59
Show Gist options
  • Save mohamad-shafaee/f6c934dd5045d73d3453ca36e0576890 to your computer and use it in GitHub Desktop.
Save mohamad-shafaee/f6c934dd5045d73d3453ca36e0576890 to your computer and use it in GitHub Desktop.
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