Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.app.Activity;
- import android.content.Context;
- import android.graphics.Canvas;
- import android.graphics.Color;
- import android.graphics.Paint;
- import android.graphics.Rect;
- import android.graphics.RectF;
- import android.os.Bundle;
- import android.os.Handler;
- import android.view.View;
- public class ActivityTeste extends Activity implements Runnable {
- int angle = 1;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Handler handler = new Handler();
- for(int i = 0;i < 360;i++) {
- handler.postDelayed(this, 100 * i/10);
- }
- }
- private class Teste extends View {
- int angle;
- public Teste(Context context, int angle) {
- super(context);
- this.angle = angle;
- }
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
- paint.setColor(Color.GREEN);
- paint.setAlpha(50);
- RectF rect = new RectF(new Rect(0, 0, 300, 300));
- canvas.drawArc(rect, 270, angle, true, paint);
- invalidate();
- }
- }
- @Override
- public void run() {
- setContentView(new Teste(this, this.angle++));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment