Book Image

Building Android UIs with Custom Views

By : Raimon Ràfols Montane
Book Image

Building Android UIs with Custom Views

By: Raimon Ràfols Montane

Overview of this book

To build great user interfaces for your Android apps that go beyond the standard UI elements, you need to use custom Android views. With these, you can give your app a distinctive look and ensure that it functions properly across multiple devices. This book will help you construct a great UI for your apps by teaching you how to create custom Android views. You will start by creating your first Android custom view and go through the design considerations. You will then see how the right choices will enable your custom view to perform seamlessly across multiple platforms and Android versions. You will create custom styleable attributes that work with Android XML layouts, learn to process touch events, define custom attributes, and add properties and events to them. By the end of this book, you will be able to create apps with custom views that are responsive and adaptable to make your app distinctive and an instant hit with its users.
Table of Contents (12 chapters)

Implementing Your First Custom View

In the previous chapter, we've seen how to create the foundations of a custom view, but unless we add some more features and customizations it'll be pretty useless. In this chapter, we'll continue building on top of these foundations, see how we can parameterize our custom view to allow either ourselves or any other developer to customize them, and at the end, cover some rendering that will enable us to build slightly more complex custom views.

In addition, as we've mentioned in the previous chapter, we can create custom layouts as well. In this chapter, we'll see how to create a simple custom layout.

In more detail, we'll cover the following topics:

  • Measuring and parameterizing our custom view
  • Instantiating custom views
  • Creating custom layouts
  • Basic rendering