* transform coordinates
* clip rectangle or path (expensive)
* save/restore clip and transform
(matrix all the way down)
Canvas
* draw
Slide 7
Slide 7 text
Canvas
can draw
color
line
rect
circle
arc
path
point
text
bitmap
Slide 8
Slide 8 text
Paint
color
style
stroke
...
Slide 9
Slide 9 text
Shader
PathEffect
Xfermode
text
Paint
advanced
Slide 10
Slide 10 text
hardware acceleration
* will make you suffer
* enabled by default when target API >= 14
* many drawing calls are not supported
* notable mention: setLayerType
DRAW
* extend View or any descendent
* override onDraw and draw on the Canvas
* to trigger draw pass -> invalidate
* tip: if no background -> setWillNotDraw(false)
Slide 14
Slide 14 text
MEASURE & LAYOUT
* override onMeasure
* specs can be UNDEFINED, EXACTLY or AT_MOST
* must call setMeasuredDimension
* to trigger measure/layout pass -> requestLayout
* children handle layout in onSizeChanged
Slide 15
Slide 15 text
CUSTOM LAYOUT
* extend ViewGroup or any descendent
* override onLayout and measure + layout each child
* children ready in onFinishInflate
* added/removed in OnHierarchyChangeListener
* can use custom LayoutParams to hold child data
Slide 16
Slide 16 text
EXTRAS
* save/restore instance state
* use XML attrs
* use attach state change callback
* harness the power of drawable state
* test your UI on slow and/or big devices
WITH data binding
LINKS
Mastering the Android Touch System (talk)
https://goo.gl/KzoUVE
The mysterious case of who killed arcs on Android
https://goo.gl/gWLZ71
Hinting Around: Android text demystified (talk)
https://goo.gl/3vyehQ
use the Source!
Creating Custom Views (official documentation)
http://goo.gl/cPbWQW
Hardware Acceleration (official documentation)
http://goo.gl/AEL1O5
Romain Guy blog
http://goo.gl/iUjZPH
Dianne Hackborn – about Hardware Acceleration
https://goo.gl/tpZ7ex