Android 시계

Programming/Android 2013. 8. 19. 16:59 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
package com.tistory.tansanc.Test130805;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;

public class MainActivity extends Activity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MyView mv = new MyView(this);
		setContentView(mv);
	}
}

class MyView extends View {
	Context context;

	public MyView(Context context) {
		super(context);
		this.context = context;
		mHandler.sendEmptyMessage(0);
	}

	float degree = -30;

	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub

		Paint Pnt = new Paint();
		Pnt.setAntiAlias(true);
		Pnt.setColor(Color.YELLOW);
		Pnt.setStrokeWidth(20);
		
		canvas.translate(canvas.getWidth()/2, canvas.getHeight()/2);
		canvas.rotate(degree);
		canvas.drawLine(0, 0, 400, 400, Pnt);
		Pnt.setColor(Color.RED);
		Pnt.setStrokeWidth(10);
		canvas.rotate(degree);
		canvas.drawLine(0, 0, 400, 400, Pnt);
		super.onDraw(canvas);
	}

	Handler mHandler = new Handler() {
		public void handleMessage(Message msg) {
			degree++;
			invalidate();
			mHandler.sendEmptyMessageDelayed(0, 100);
		}
	};
}

'Programming > Android' 카테고리의 다른 글

Android Download html  (0) 2013.08.20
Andoid 매트로돔  (0) 2013.08.19
Andoid 알람 기능으로 라디오 mms 주소로 듣기  (0) 2013.08.16
Android 라디오 mms 주소로 듣기  (1) 2013.08.16
Android Intro 로딩 Activity  (0) 2013.08.12