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 FrameLayout).

  1. Create a new Java source file in the root package of the project named CircleLayout.java, and open it in your editor or IDE.
  2. Declare the CircleLayout as extending the ViewGroup class:
    public class CircleLayout extends ViewGroup
    
  3. Declare the three ViewGroup constructors and have them delegate directly to the ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.