Android Custom Views
-
Upload
raimon-rafols -
Category
Mobile
-
view
17 -
download
0
Transcript of Android Custom Views
What your mother didn't tell you about Custom Views
Who I am?
Raimon Rfols@rrafols+RaimonRafolsMontanehttp://blog.rafols.org
Software Engineering ManagerImagination Technologies
@ImaginationPRimgtec.com
Custom ViewsMotivation
Why?
Advantages?
Benefits?
Should we use them on all kind of projects?
Or should we prioritise the use of standard components only?
Isn't it too much effort?
DesignProgrammingTesting
Let's build one Custom View!
Is that all?
What's the result?
Layout parameters
MATCH_PARENT
WRAP_CONTENT
SPECIFIC SIZE
MeasureSpec.AT_MOST
MeasureSpec.EXACTLY
MeasureSpec.UNSPECIFIED
What's the mapping between these values?
WIDTH: EXACTLYHEIGHT: EXACTLY
WIDTH: EXACTLYHEIGHT: AT_MOST
WIDTH: EXACTLYHEIGHT: UNSPECIFIED
Parametrise
Define parameters ina xml resource fileattrs.xml
Be nice - Always recycle!
Tips
Don't create Paint objects on onDraw. As a rule of thumb don't allocate memory on draw methods.
API support & limitations
What could be done?
Detect version on runtime and adapt dynamically
?
http://developer.android.com/guide/topics/graphics/hardware-accel.html
@rrafolshttp://blog.rafols.org