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)

Handling Events

Now that we've seen the basics of canvas drawing and we've our custom view adapted to its size, it's time to interact with it. Many custom views will only need to draw something in a special way; that's the reason we created them as custom views, but many others will need to react to user events. For example, how our custom view will behave when the user clicks or drags on top of it?

To answer these questions, we'll cover with more detail the following points in this chapter:

  • Basic event handling
  • Advanced event handling