Book Image

Android User Interface Development: Beginner's Guide

By : Jason Morris
Book Image

Android User Interface Development: Beginner's Guide

By: Jason Morris

Overview of this book

<p>There are over 30,000 applications for Android that have been downloaded over a million times already. What makes yours any different? Building a compelling user-interface that people understand and enjoy is vital for the survival of a new application in an environment where look and feel may be the only thing between a user purchasing your application; or deleting it forever.<br /><br />Working through examples, code-snippets, and screenshots this book introduces the fundamentals of good user-interface design from a developer's point of view. This book will put you above the rest by showing you how to build striking user interfaces to grasp your app users' attention enough to make them shell out some bucks to buy your application.</p> <p>The <em>Android User Interface Development Beginner's Guide</em> will tell you everything you need to know to style your applications from bottom up. Given the importance of user-interface design on a touch-screen device, this book aims to equip its reader with the knowledge required to build killer Android applications. Starting simply, and keeping things easy, this book will take you on a step-by-step journey to understanding the principals of good user-interface design, and how to implement the best user interfaces on an Android mobile device. It aims at building design understanding on a chapter-by-chapter basis, while introducing platform knowledge through examples.</p>
Table of Contents (18 chapters)
Android User Interface Development
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

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 ViewGroup default constructors:

    public CircleLayout(Context context) {
        super(context);
    }
    // ...
  4. We'll need to know the largest number of pixels taken up by a child View object's width, and the largest number of pixels taken up by a child View object...