2012 All rights reserved 2012 All rights reserved
- Slides: 42
전체적인 구조 © 2012 생능출판사 All rights reserved
예제 © 2012 생능출판사 All rights reserved
예제 © 2012 생능출판사 All rights reserved
몇 개의 기초 도형 그리기 @Override protected void on. Draw(Canvas canvas) { Paint paint = new Paint(); paint. set. Color(Color. YELLOW); canvas. draw. Color(Color. BLUE); canvas. draw. Round. Rect(new Rect. F(30, 50, 330, 550), 15, paint); canvas. draw. Oval(new Rect. F(450, 750, 550), paint); paint. set. Color(Color. RED); canvas. draw. Arc(new Rect. F(30, 600, 330, 1100), 360, 1000, true, paint); paint. set. Color(Color. YELLOW); float[] pts={ 30, 1250, 300, 1350, 60, 1450, 360, 1500}; paint. set. Stroke. Width(10); canvas. draw. Lines(pts, paint); } © 2012 생능출판사 All rights reserved
커스텀 뷰를 XML에서 참조하기 <? xml version="1. 0" encoding="utf-8"? > <Linear. Layout xmlns: android="http: //schemas. android. com/apk/res/android" android: layout_width="match_parent" android: layout_height="match_parent" android: orientation="vertical" > <kr. company. customview. Custom. View android: layout_width="match_parent" android: layout_height="match_parent" /> </Linear. Layout> © 2012 생능출판사 All rights reserved
커스텀 뷰를 XML에서 참조하기. . . public class Custom. View extends View { public Custom. View(Context context) { super(context); set. Background. Color(Color. YELLOW); } public Custom. View(Context context, Attribute. Set attrs) { super(context); set. Background. Color(Color. YELLOW); } @Override protected void on. Draw(Canvas canvas) { Paint paint = new Paint(); paint. set. Color(Color. RED); canvas. draw. Arc(new Rect. F(10, 120, 110, 220), 120, 270, true, paint); } } © 2012 생능출판사 All rights reserved
색상 색의 3원색인 Red, Green, Blue 성분을 8비트로 표시 paint. set. Color(0 x. FF 0000); paint. set. Color(Color. RED); © 2012 생능출판사 All rights reserved
원호그리기 class My. View extends View { private Paint m. Paints, m. Frame. Paint; private Rect. F m. Big. Oval; private float m. Start, m. Sweep; private static final float SWEEP_INC = 2; private static final float START_INC = 15; public My. View(Contextcontext) { super(context); m. Paints = new Paint(); m. Paints. set. Anti. Alias(true); m. Paints. set. Style(Paint. Style. FILL); m. Paints. set. Color(0 x 88 FF 0000); m. Frame. Paint = new Paint(); m. Frame. Paint. set. Anti. Alias(true); m. Frame. Paint. set. Style(Paint. Style. STROKE); m. Frame. Paint. set. Stroke. Width(3); m. Frame. Paint. set. Color(0 x 8800 FF 00); m. Big. Oval = new Rect. F(100, 40, 900, 1000); } © 2012 생능출판사 All rights reserved
원호그리기 @Override protected void on. Draw(Canvas canvas) { canvas. draw. Color(Color. YELLOW); canvas. draw. Rect(m. Big. Oval, m. Frame. Paint); canvas. draw. Arc(m. Big. Oval, m. Start, m. Sweep, false, m. Paints); m. Sweep += SWEEP_INC; if (m. Sweep >360) { m. Sweep -= 360; m. Start += START_INC; if (m. Start >= 360) m. Start -= 360; } invalidate(); } } public class Main. Activity extends App. Compat. Activity { protected void on. Create(Bundlesaved. Instance. State) { super. on. Create(saved. Instance. State); set. Content. View(new My. View(this)); } } © 2012 생능출판사 All rights reserved
원호그리기 © 2012 생능출판사 All rights reserved
폰트 © 2012 생능출판사 All rights reserved
폰트 예제. . . @Override protected void on. Draw(Canvas canvas) { Paint paint = new Paint(); paint. set. Anti. Alias(true); paint. set. Text. Size(100); Typeface t; t = Typeface. create(Typeface. DEFAULT, Typeface. NORMAL); paint. set. Typeface(t); canvas. draw. Text("DEFAULT 폰트", 10, 400, paint); t = Typeface. create(Typeface. DEFAULT_BOLD, Typeface. NORMAL); paint. set. Typeface(t); canvas. draw. Text("DEFAULT_BOLD 폰트", 10, 600, paint); t = Typeface. create(Typeface. MONOSPACE, Typeface. NORMAL); paint. set. Typeface(t); canvas. draw. Text("MONOSPACE 폰트", 10, 800, paint); t = Typeface. create(Typeface. SERIF, Typeface. NORMAL); paint. set. Typeface(t); canvas. draw. Text("SERIF 폰트", 1000, paint); t = Typeface. create(Typeface. SANS_SERIF, Typeface. NORMAL); paint. set. Typeface(t); © 2012 생능출판사 All rights reserved canvas. draw. Text("SANS_SERIF 폰트", 10, 1200, paint); }
외부 폰트 사용 @Override protected void on. Draw(Canvas canvas) { Typeface my. Font; Paint paint = new Paint(); paint. set. Anti. Alias(true); my. Font = Typeface. create. From. Asset(get. Context(). get. Assets(), "animeace 2_ital. ttf"); paint. set. Typeface(my. Font); paint. set. Text. Size(25); canvas. draw. Text("This is a New Font!!!", 100, paint); canvas. draw. Text("Have Fun!!!", 10, 200, paint); } © 2012 생능출판사 All rights reserved
이미지 표시하기: Image. View 사 용 © 2012 생능출판사 All rights reserved
코드로 화면에 이미지 표시 class My. View extends View { public My. View(Context context) { super(context); set. Background. Color(Color. YELLOW); } @Override protected void on. Draw(Canvas canvas) { Paint paint = new Paint(); Bitmap b = Bitmap. Factory. decode. Resource(get. Resources(), R. drawable. cat); canvas. draw. Bitmap(b, 0, 0, null); } } public class Image. Disp. Activity extends Activity { @Override public void on. Create(Bundle saved. Instance. State) { super. on. Create(saved. Instance. State); My. View w = new My. View(this); set. Content. View(w); } } © 2012 생능출판사 All rights reserved
이미지 크기 변환 행렬 사용 . . . Matrix m = new Matrix(); m. pre. Scale(1, -1); Bitmap b = Bitmap. Factory. decode. Resource(get. Resource(), R. drawable. android); Bitmap mb=Bitmap. create. Bitmap(b, 0, 0, b. get. Width(), b. get. Height(), m, false); . . . © 2012 생능출판사 All rights reserved
이미지 크기 변환. . . protected void on. Draw(Canvas canvas) { Paint paint = new Paint(); Matrix m= new Matrix(); m. pre. Scale(1, -1); Bitmap b = Bitmap. Factory. decode. Resource(get. Resources(), R. drawable. house); Bitmap mb = Bitmap. create. Bitmap(b, 0, 0, b. get. Width(), b. get. Height(), m, false); Bitmap sb = Bitmap. create. Scaled. Bitmap(b, 200, false); canvas. draw. Bitmap(mb, 0, 0, null); canvas. draw. Bitmap(sb, 100, null); }. . . © 2012 생능출판사 All rights reserved
XML로 도형 객체 정의 <? xml version="1. 0" encoding="utf-8"? > <shape xmlns: android="http: //schemas. android. com/apk/res/android" android: shape=["rectangle" | "oval" | "line" | "ring"] > <corners. . /> <gradient. . /> <padding. . /> <size. . /> <solid android: color="color" /> <stroke android: width="integer". . /> </shape> © 2012 생능출판사 All rights reserved
XML로 도형 객체 정의: 예제 <? xml version="1. 0" encoding="utf-8"? > <shape xmlns: android="http: //schemas. android. com/apk/res/android" android: shape="oval"> <solid android: color="#ff 0000"/> </shape> © 2012 생능출판사 All rights reserved
XML로 도형 객체 정의: 예제. . . Linear. Layout m. Linear. Layout; protected void on. Create(Bundle saved. Instance. State) { super. on. Create(saved. Instance. State); m. Linear. Layout = new Linear. Layout(this); Image. View i = new Image. View(this); i. set. Image. Drawable(R. drawable. oval); i. set. Minimum. Height(100); i. set. Minimum. Width(100); m. Linear. Layout. add. View(i); set. Content. View(m. Linear. Layout); }. . . © 2012 생능출판사 All rights reserved
예제 public class Main. Activity extends App. Compat. Activity { private Linear. Layout layout; private Button fade. Button, slide. Button, explode. Button; private Image. View image. View, image. View 2; boolean visible; @Override protected void on. Create(Bundle saved. Instance. State) { super. on. Create(saved. Instance. State); set. Content. View(R. layout. activity_main); layout = (Linear. Layout) find. View. By. Id(R. id. layout); fade. Button = (Button) find. View. By. Id(R. id. fade); slide. Button = (Button) find. View. By. Id(R. id. slide); explode. Button = (Button) find. View. By. Id(R. id. explode); image. View = (Image. View) find. View. By. Id(R. id. imageview); © 2012 생능출판사 All rights reserved
예제 fade. Button. set. On. Click. Listener(new View. On. Click. Listener() { @Override public void on. Click(View view) { Transition. Manager. begin. Delayed. Transition(layout, new Fade()); visible = !visible; image. View. set. Visibility(visible ? View. VISIBLE : View. GONE); } }); slide. Button. set. On. Click. Listener(new View. On. Click. Listener() { @Override public void on. Click(View view) { Transition. Manager. begin. Delayed. Transition(layout, new Slide()); visible = !visible; image. View. set. Visibility(visible ? View. VISIBLE : View. GONE); } }); © 2012 생능출판사 All rights reserved
예제 explode. Button. set. On. Click. Listener(new View. On. Click. Listener() { @Override public void on. Click(View view) { Transition. Manager. begin. Delayed. Transition(layout, new Explode()); visible = !visible; image. View. set. Visibility(visible ? View. VISIBLE : View. GONE); } } © 2012 생능출판사 All rights reserved
실행 결과 © 2012 생능출판사 All rights reserved
예제 © 2012 생능출판사 All rights reserved
Lab: 랜덤 그래픽 작성 © 2012 생능출판사 All rights reserved
© 2012 생능출판사 All rights reserved
핵심 코드 © 2012 생능출판사 All rights reserved
- Specification by example
- Copyright 2015 all rights reserved
- All rights reserved sentence
- Freesound content licence
- Confidential all rights reserved
- All rights reserved example
- Copyright 2015 all rights reserved
- 2012 pearson education inc
- Microsoft corporation. all rights reserved.
- Microsoft corporation. all rights reserved.
- Microsoft corporation. all rights reserved.
- Pearson education inc. all rights reserved
- Dell all rights reserved copyright 2009
- Warning all rights reserved
- Siprop
- All rights reserved formula
- Warning all rights reserved
- Confidential all rights reserved
- Microsoft corporation. all rights reserved
- 2010 pearson education inc
- Copyright © 2018 all rights reserved
- Gssllc
- Pearson education inc all rights reserved
- Pearson education inc. all rights reserved
- Confidential all rights reserved
- Confidential all rights reserved
- R rights reserved
- Rights reserved
- Positive rights and negative rights
- Littoral rights vs riparian rights
- Conclusion of rights
- Legal rights vs moral rights
- What are negative rights
- Negative rights
- Rosalind hursthouse
- Negative right
- Name a line containing point a
- How do delegated, reserved, and concurrent powers differ?
- National powers
- Reserved power
- Mpls label format
- The excitement that lingers after a frightening event
- Find the names of sailors who have reserved a red boat