Drawable 발표
description
Transcript of Drawable 발표
장인수
Drawable Resource
01Class Overview
A Drawable is a general abstraction for "something that can be drawn."
Most often you will deal with Drawable as the type of resource retrieved
for drawing things to the screen;
the Drawable class provides a generic API for dealing with an underlying
visual resource that may take a variety of forms.
Unlike a View, a Drawable does not have any facility to receive events
or otherwise interact with the user.
02Drawable 정의 , 인스턴스화 방법
Drawable 정의하고 인스턴스화하는 3 가지 방법
1. 리소스 이미지에서 생성하기 ( 프로젝트 리소스에 저장된 이미지 사용하기 )
2. 리소스 XML 에서 생성하기 (Drawable properties 을 정의하는 XML 파일사용하기 )
3. 일반적인 클래스 생성자 .
03이미지 리소스에서 생성하기
리소스 이미지에서 생성하기
아래 소스코드는 drawable resouce 로부터 image 를 사용하여ImageView 를 만들고 , 이것을 Layout 에 추가하는 방법을 보여준다 .
04리소스 XML 에서 생성하기
리소스 XML 에서 생성하기
XML 로 drawable 을 정의 했다면1. 그 파일을 res/drawable/ 디렉토리에 저장하고 그런 다름에2. Resources.getDrawables() 을 호출하고 3. 그것에 만든 XML 파일에 대한 리소스 ID 를 전달하므로써 오브젝트를 가져와서 인스턴스화한다 .
[ 예제 1]
저장 (save)
[ 예제 2]
05일반적인 클래스 생성자
일반적인 클래스 생성자
06AnimationDrawable
AnimationDrawable(xml)
07AnimationDrawable
AnimationDrawable(code)
08질의응답
Q & A