Androidology - Architecture Overview [ link ]
Google I/O 2009 - ...Make your Android UI Fast and Efficient [ link ] (good one!)
onLayout()
draw()
dispatchDraw()
onDraw()
dispatchTouchEvent()
Decompose the app into application building blocks, which include
Androidology - APIs [ link ]
- Activities
- BroadcastReceivers (triggered by any event)
- Services
- ContentProviders
Androidology - APIs [ link ]
Google I/O 2009 - ...Make your Android UI Fast and Efficient [ link ] (good one!)
- reuse views with Recycler for higher fps
- prescale bitmaps with
image = Bitmap.createPrescaledBitmap(image, view.getWidth(), view.getHeight(), true); - remove backgrounds from views, which fill parents full width and height (eg if you have a map, you don't see the background, which is still rendered) [00:17:23]
- invalidate() to redraw a view is inefficient, use invalidate(rect) or invalidate(left, top, right, bottom)
- fewer (views) is better ;) (try to get rid of views that have only one child, too: HierarchyViewer)
- use compound drawables (eg TextView instead of ImageView+TextView)
- use ViewStub to inflate part of the UI on demand (eg for part of the UI that for majority of the time is invisible) [00:35:20]
- use merge tag to reuse UI hierarchy elements
- RelativeLayout instead of embedding linear layouts; hard to use, but it pays off
- use custom views, custom layouts instead of overusing numerous views
- garbage collection kicks in for 100~500ms, stops threads (so allocate little memory, or even none :d)
- do not allocate memory in those time-critical points:
onLayout()
draw()
dispatchDraw()
onDraw()
dispatchTouchEvent()