Creating New Views

The ability to extend existing Views, assemble composite controls, and create unique new Views lets you implement beautiful user interfaces optimized for your application's workflow. Android lets you subclass the existing View toolbox or implement your own View controls, giving you total freedom to tailor your UI to optimize the user experience.

When you design a user interface it's important to balance raiv aesthetics and usability. With the power to create your own custom controls comes the temptation to rebuild all your controls from scratch. Resist that urge. The standard Views will be familiar to users from other Android applications and will update in line with new platform releases. On small screens, with users often paying limited attention, familiarity can often provide better usability than a slightly shinier control.

The best approach to use when creating a new View depends on what you want to achieve:

> Modify or extend the appearance and/or behavior of an existing control when it already supplies the basic functionality you want. By overriding the event handlers and onDraw, but still calling back to the superclass's methods, you can customize a View without having to reimplement its functionality. For example, you could customize a TextView to display a set number of decimal points.

> Combine Views to create atomic, reusable controls that leverage the functionality of several interconnected Views. For example, you could create a dropdown combo box by combining a TextView and a Button that displays a floating ListView when clicked.

> Create an entirely new control when you need a completely different interface that you can't get by changing or combining existing controls.

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Post a comment