Time for action - creating a custom layout
To really demonstrate the use of a custom layout, you need to try building something unusual. In the following example, you'll put together a
ViewGroup that arranges its children in a nice circle. It's not a very brilliant layout, nor is it particularly useful, but circles are nice to look at, and it would provide useful negative space in the screen center (which could be filled using a
- Create a new Java source file in the root package of the project named
CircleLayout.java, and open it in your editor or IDE.
- Declare the
CircleLayoutas extending the
public class CircleLayout extends ViewGroup
- Declare the three
ViewGroupconstructors and have them delegate directly to the ...