Custom Drawing with Canvas
summary
Shows how to replace many small Views with a single custom View drawn on android.graphics.Canvas, using actual code: creating Paint objects, computing column widths, drawing axes, grid lines and rectangles for a working bar chart, and a reusable Drawable that draws a circle avatar with centered text. Covers text via static layout and SpannableString, animating values with ValueAnimator, and the performance rule: initialize up front, keep onDraw under 16 ms so the animation runs at 60 fps.
AI-written summary · about
chapters (20)
- 0:00Intro
- 2:30Where do we start
- 3:39Getting a Canvas
- 4:52Painting
- 6:14Navigation
- 7:35Bar Chart
- 9:07Override View
- 10:32Drawing Dimensions
- 11:42Drawing Components
- 14:06Drawing Individual Bars
- 20:28View Groups
- 23:15Drawables
- 27:17Text Paint
- 31:30Text Layouts
- 35:07Initialize Colors
- 40:33Override Draw
- 43:50Review
- 44:36Transform Canvas
- 45:53Heart Animation
- 47:11Questions
related talks
40mPlease, Draw Me a View
51mMeasure, Layout, Draw, Repeat: Custom Views and ViewGroups
32mA Skeptics Guide to Programmatic Views on Android
27mCustom Views - The Definitive Guide
42mMeasure. Layout. Draw. Repeat: Custom Views and ViewGroups
51mCrafting Custom Android Views
40mWriting Custom Views for Android
18mAdvanced Android Canvas APIs
