Graphics Flashcards

1
Q

Define what a drawable is…

A

An XML file used to define visual elements such as graphics, icons and backgrounds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give some drawable types…

A

Bitmap, vector, shape layer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define what a canvas is…

A

An object that provides methods that enable drawing graphics onto a View and SurfaceView.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the 4 classes required to draw with a canvas?

A

View -> Displays a bitmap.
Bitmap -> Provide a surface to draw on.
Canvas -> API to draw on the Surface.
Paint -> Style what’s been drawn.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define a SurfaceView…

A

A type of View that is dedicated to being drawn on, and operates off the UI thread.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When creating a SurfaceView, what must the class extend and impement?

A

Extends SurfaceView
Implements Runnable, SurfaceHolder.Callback

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are SurfaceViews and Generic Views used for?

A

Both are used for drawing graphics. Views are used for more simple graphics due to being on the UI thread, whereas SurfaceViews are used for more complex graphic implementations due to operating off the UI thread.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the differences between drawing on a SurfaceView and a Generic View? Give a pro and con of using each…

A

SurfaceView provides a separate Surface for drawing, and drawing operation is done on a worker thread. It’s more efficient due to performing drawing on a worker thread. However, is more complicated due to thread management.

Generic View is drawn on the UI thread. This has less overhead due to no creation and management of other threads. However, should only be used with simple graphics to to prevent overloading UI thread.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When should a SurfaceView be used?

A

When doing complex, computationally expensive graphics operations such as animations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When should a Generic View be used?

A

When doing simple, unchanging graphics such as drawing images on buttons.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Give the 3 steps to drawing a Generic View?

A

1) Create a class that extends View. Override onDraw and onTouchEvent.
2) Add the custom view to the layout XML file.
3) When the View is inflated, the onCreate( ) method is called, and displays the generic View.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Define the 3 steps to drawing on a SurfaceView…

A

1) Define SurfaceView -> Create a class that extends SurfaceView and implements Runnable, SurfaceHolder.Callback. Call getHolder( ) to get a reference to the SurfaceHolder.
2) Setup and draw to the SurfaceView -> Define run( ) to create thread implementation, and start thread in surfaceCreated( ).
3) Handle User Interactions -> resume( ) and pause( ).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In which SurfaceView callback method is the drawing thread started?

A

surfaceCreated( ).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does implementing a SurfaceHolder.Callback do?

A

Enables implementation of the callback methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What object does the onDraw( ) method provide?

A

A Canvas object which can then be used to perform drawing operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which thread to Generic Views use to draw?

A

UI thread.

17
Q

Which thread do SurfaceViews use to draw?

A

Render thread.