Welcome to this review of the Pluralsight course Android Custom Components by Chiu-Ki Chan.
Chiu-Ki is a mobile developer with a passion in speaking and teaching.
She runs a mobile development company, producing apps such as “Monkey Write” for learning Chinese writing and Heart Collage for snapping photos to stitch into a heart.
Android Layout Fundamentals is the 11th course in the Android Learning Path.
Android Custom Components
Chiu-Ki begins by categorizing the built-in components that Android provides:
- Simple View (e.g. TextView)
- Container (e.g. LinearLayout, ListView, GridView)
- Compound Control (e.g. TimePicker)
So why might we want to create a custom component? Chiu-Ki gives 4 reasons:
- Modularize repeated code
- Access protected methods
- Optimize rendering speed
- Complete control with draw, measure and layout
Chiu-Ki says there are several techniques usedin this course:
- Shortcut View and ViewGroup – for modularizing repeated code
- Custom View – for customizing size and appearance of simple view
- Custom ViewGroup – Container for child views
In this course these techniques are learnt using a couple of fun examples:
- Photo spiral
Extend a simple view
In this module we:
- Reuse parent class functionality
- Add only the part we need
- Modularize code into custom view
We make our first custom view and use 3 constructors: 1 for Java, 1 for xml and 1 for xml with style.
We learn that we should choose a parent view closest to what we need.
We learn that a compound control is a group of views, often with additional functionalities.
We look at the LengthPicker: a LinearLayout with 2 buttons and a TextView.