O'Reilly logo

Android User Interface Development by Jason Morris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required