간단한 안드로이드 그림판 소스입니다.
본 자료는 미리보기를 지원하지 않습니다.
닫기
  • 1
  • 2
  • 3
해당 자료는 1페이지 까지만 미리보기를 제공합니다.
1페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

간단한 안드로이드 그림판 소스입니다.에 대한 보고서 자료입니다.

목차

Mainactivity.java

본문내용

.
.
.
class Point {
float x;
float y;
boolean isDraw;
public Point(float x, float y, boolean isDraw) {
. . .
}
}
.
.


class MyPaint extends View { ... }

//------------------------------
import java.util.ArrayList;

import android.annotation.SuppressLint;
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.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;

@SuppressLint(\\"DrawAllocation\\")
public class MainActivity extends Activity {
class Point {
float x;
float y;
boolean isDraw;
public Point(float x, float y, boolean isDraw) {
this.x = x;
this.y = y;
this.isDraw = isDraw;
}
}
class MyPaint extends View {
public MyPaint(Context context) {
super(context);
setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
this.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch( event.getAction() ) {
case MotionEvent.ACTION_MOVE:
points.add(new Point(event.getX(), event.getY(), true));
invalidate();
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_DOWN:
points.add(new Point(event.getX(), event.getY(), false));
}
return true;
}
});
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint p = new Paint();
p.setColor(Color.MAGENTA);
p.setStrokeWidth(3);
for(int i=1; i if(!points.get(i).isDraw) continue;
canvas.drawLine(points.get(i-1).x, points.get(i-1).y, points.get(i).x, points.get(i).y, p);
}
}
}
ArrayList points = new ArrayList();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyPaint mp = new MyPaint(this);
setContentView(mp);
}
}
  • 가격2,000
  • 페이지수3페이지
  • 등록일2014.06.02
  • 저작시기2014.3
  • 파일형식압축파일(zip)
  • 자료번호#921114
본 자료는 최근 2주간 다운받은 회원이 없습니다.
다운로드 장바구니