Custom Widget 1 UNIT 26 로봇 SW 콘텐츠 교육원 조용수. 캔버스 public void drawColor(int color) 2 public class ControllerView extends View { public ControllerView(Context.

Slides:



Advertisements
Similar presentations
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Advertisements

Life Cycle of an Applet, along with response to mouse events and other simple features. (ps:only two possible examples for life circle of an Applet)
Laboratory Study II October, Java Programming Assignment  Write a program to calculate and output the distance traveled by a car on a tank of.
Graphics Chapter 16.  If you want to draw shapes such as a bar chart, a clock, or a stop sign, how do you do it?
Cosc 5/4730 Blackberry Drawing. Screen size With Blackberry devices, they have a known screen size in pixels. If you are programming for specific device.
LAB SESSION 7 Graphical user interface Applet fundamentals Methods in applets Execution of an applet Graphics class.
Multithreading : animation. slide 5.2 Animation Animation shows different objects moving or changing as time progresses. Thread programming is useful.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
My own View Android development Maarten Pennings 2011 oct 14.
Crash Course in Android Development. 2 Content  Installing the ADT  Hardware and OS requirements  Java  ADT Bundle  Eclipse Project Setup  Drawing.
2D Graphics: Part 1. Android Graphics Libraries 2D Graphics –custom 2D graphics library in packages android.graphics android.graphics.drawable android.graphics.drawable.shapes.
Custom Views, Drawing, Styles, Themes, ViewProperties, Animations, oh my!
Basic Drawing Techniques
2D Graphics: Part 2.
Programming Concepts. Derive a new class from Activity of the framework Prepare the data beforehand, e.g., vertices, colours, normal vectors, texture.
Android Tutorial Team 3 Jerry Yu Mayank Mandava Mu Du Will Wangles.
로봇 모니터링 2/2 UNIT 21 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Broadcasting Service 2.
1 Mobile Computing Advanced Touching Copyright 2014 by Janson Industries Assg Part1Assg Part1 AssgPart2AssgPart2.
로봇 전화번호부 4/4 UNIT 12 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 뷰 홀더 패턴을 사용할 수 있다. 토스트를 사용할 수 있다. 클릭 이벤트를 처리할 수 있다. 2.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 스마트 폰의 센서를 사용할 수 있다. 2.
로봇 모션 편집기 4/4 UNIT 25 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 에디트 텍스트를 사용할 수 있다. 아이템을 삭제할 수 있다. 아이템을 편집할 수 있다. 2.
Android Graphics Library. Color Android colors are represented with four numbers, one each for alpha, red, green, and blue (ARGB). Each component can.
로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Message Queue Handler 2.
Activity 생명주기 UNIT 13 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Logcat 액티비티 생명주기를 설명할 수 있다. 현재 상태를 저장할 수 있다. 2.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Ch3. 캔버스 활용 3-2 도형으로 안드로이드 캐릭터 만들기.
데이터 저장 & Fragment UNIT 28 로봇 SW 콘텐츠 교육원 조용수. 데이터 저장 & Fragment SharedPreference 로 데이터 저장 Fragment 의 이해 2.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Cosc 5/4730 Android drawing. Screen support Android is the OS and is used a many different hardware created by different vendors. – Screen size For simplicity,
Android Threads. Threads Android will show an “ANR” error if a View does not return from handling an event within 5 seconds Or, if some code running in.
BallWorld.java Ball.java A functional walkthrough Part 3: the interaction of objects.
CHAP 8. 고급 그래픽과 O PEN GL. © 2012 생능출판사 All rights reserved C ANVAS 클래스와 P AINT 클래스.
Chapter 2: Graphics In Java Basics of classes –instance variables –methods –overriding methods Graphics class (drawing routines) Other classes –Color –Font.
CHAP 8. 그래픽.
네트워크 전송 1/2 UNIT 29 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Android Network 통신 2.
Android Application Lifecycle and Menus
로봇을 조종하자 4/4 UNIT 18 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Intent Activity 호출 2.
ANDROID 中的 2D 繪圖 作者:陳鍾誠. ANDROID 架構與 2D 繪圖 SGL: 繪圖引擎 Surface Manager 繪圖管理者.
로봇을 조종하자 1/5 UNIT 14 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 터치 이벤트를 처리할 수 있다. 2.
Custom Widget 2 UNIT 27 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Custom Widget –Canvas 를 이용하여 Custom Widget 을 만든다. 2.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
© 2012 생능출판사 All rights reserved CHAP 8. 그래픽. © 2012 생능출판사 All rights reserved 안드로이드에서의 2 차원 그래픽 사용 방법 1) XML 파일로 그래픽이나 애니메이션을 정의한다. 그리는 작업은 안드로이드 시스템이.
David Sutton 2D GRAPHICS IN ANDROID. INTRODUCTION AND OUTLINE  In this week’s session we will create a simple Kaleidoscope application. Topics that will.
CHAP 8. 그래픽. © 2012 생능출판사 All rights reserved 안드로이드에서의 그래픽 XML 파일로 그래픽이나 애니메이션을 정의한다. 그 리는 작업은 안드로이드 시스템이 담당한다. onDraw() 메소드 안에 draw...() 와 같은 메소드를 호.
2D Graphics: Part 1.
TUTORIAL ON MULTITOUCH AND SWIPE GESTURES
UNIT 11 로봇 전화번호부 3/4 로봇 SW 콘텐츠 교육원 조용수.
GUI Programming Fundamentals
滑動版面 建國科技大學 資管系 饒瑞佶 2013/7 V1.
CS499 – Mobile Application Development
Android – Event Handling
2D Graphics: Part 2.
Android Widgets 1 7 August 2018
Mobile Computing With Android ACST 4550 Bitmaps, Fonts and Gestures
Android Programming Lecture 6
null, true, and false are also reserved.
Introduction to Java Programming
Graphics with Canvas.
CMPE419 Mobile Application Development
Chapter 8: Graphics, Animations, Sounds, and Gaming
UNIT 08 그림책 만들기 2/2 로봇 SW 콘텐츠 교육원 조용수.
JavaScript Reserved Words
Mobile Computing With Android ACST 4550 Android Database Storage
Simple Classes in Java CSCI 392 Classes – Part 1.
滑動 建國科技大學 資管系 饒瑞佶.
Mobile Programming Gestures in Android.
CIS 470 Mobile App Development
Presentation transcript:

Custom Widget 1 UNIT 26 로봇 SW 콘텐츠 교육원 조용수

캔버스 public void drawColor(int color) 2 public class ControllerView extends View { public ControllerView(Context context) { super(context); protected void onDraw(Canvas canvas) { canvas.drawColor(Color.BLUE); } public class MainActivity extends Activity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new ControllerView(this)); }

캔버스 public void drawColor(int color) 3 public class ControllerView extends View { public ControllerView(Context context) { super(context); protected void onDraw(Canvas canvas) { canvas.drawColor(0xffff0000); }

캔버스 public void drawRGB (int r, int g, int b) 4 public class ControllerView extends View { public ControllerView(Context context) { super(context); protected void onDraw(Canvas canvas) { canvas.drawRGB(255, 255, 0); }

캔버스 public void drawARGB (int a, int r, int g, int b) 5 public class ControllerView extends View { public ControllerView(Context context) { super(context); protected void onDraw(Canvas canvas) { canvas.drawARGB(100, 255, 255, 0); }

캔버스 public void drawPaint (Paint paint) Paint –public void setARGB (int a, int r, int g, int b) –public void setAlpha (int a) –public void setAntiAlias (boolean aa) –public void setColor (int color) –public void setTextSize (float textSize) 6 public class ControllerView extends View { private final Paint paint = new Paint(); public ControllerView(Context context) { super(context); protected void onDraw(Canvas canvas) { paint.setARGB(100, 255, 255, 0); canvas.drawPaint(paint); }

캔버스 public void drawLine (float startX, float startY, float stopX, float stopY, Paint paint) 7 public class ControllerView extends View { private final Paint paint = new Paint(); public ControllerView(Context context) { super(context); protected void onDraw(Canvas canvas) { paint.setColor(Color.RED); canvas.drawLine(50, 50, 300, 300, paint); }

캔버스 public void drawCircle (float cx, float cy, float radius, Paint paint) 8 public class ControllerView extends View { private final Paint paint = new Paint(); public ControllerView(Context context) { super(context); protected void onDraw(Canvas canvas) { paint.setColor(Color.RED); canvas.drawCircle(200, 200, 100, paint); }

캔버스 public void drawRect (float left, float top, float right, float bottom, Paint paint) 9 public class ControllerView extends View { private final Paint paint = new Paint(); public ControllerView(Context context) { super(context); protected void onDraw(Canvas canvas) { paint.setColor(Color.RED); canvas.drawRect(50, 50, 300, 300, paint); }

캔버스 public void drawRoundRect (RectF rect, float rx, float ry, Paint paint) 10 public class ControllerView extends View { private final Paint paint = new Paint(); public ControllerView(Context context) { super(context); protected void onDraw(Canvas canvas) { paint.setColor(Color.RED); canvas.drawRoundRect(new RectF(50, 50, 300, 300), 10, 10, paint); }

캔버스 public void drawText (String text, float x, float y, Paint paint) 11 public class ControllerView extends View { private final Paint paint = new Paint(); public ControllerView(Context context) { super(context); protected void onDraw(Canvas canvas) { paint.setColor(Color.RED); paint.setTextSize(50); canvas.drawText(" 테스트 ", 100, 100, paint); }

캔버스 public void drawPath(Path path, Paint paint) 12 public class ControllerView extends View { private final Paint paint = new Paint(); private final Path path = new Path(); private float oldX, oldY; private static final float TOUCH_TOLERANCE = 4; public ControllerView(Context context) { super(context); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(12); protected void onDraw(Canvas canvas) { canvas.drawColor(Color.WHITE); canvas.drawPath(path, paint); }

캔버스 public boolean onTouchEvent(MotionEvent event) { float x = event.getX(); float y = event.getY(); switch(event.getAction()) { case MotionEvent.ACTION_DOWN: { path.reset(); path.moveTo(x, y); oldX = x; oldY = y; invalidate(); } break; case MotionEvent.ACTION_UP: { path.lineTo(x, y); invalidate(); } break; case MotionEvent.ACTION_MOVE: { float dx = Math.abs(x - oldX); float dy = Math.abs(y - oldY); if(dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) { path.lineTo(x, y); oldX = x; oldY = y; } invalidate(); } break; } return true; }