Building Android UIs with Custom Views

Book description

Create engaging user experiences and awesome user interfaces using this guide

About This Book

  • Move beyond default UI templates, create and customize amazing UIs with Android Custom View
  • Enable smooth data flow and create futuristic UIs by creating flexible custom views
  • Scale your apps with responsive and data intensive views

Who This Book Is For

This book is for Android developers who want to create great user interfaces and move beyond the basics of the standard UI elements. They must have basic Android development knowledge along with basic Java programming.

What You Will Learn

  • Extend the standard UI widget framework by creating Custom views
  • Add complex rendering, animations, and interactions to your views
  • Optimize performance and decrease battery usage
  • Implement custom views to share between multiple projects, or share it publicly
  • Create 3D custom views using OpenGL ES

In Detail

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.

Style and approach

The approach will be that of a step by step practical tutorial. The book will take you through a complete journey, right from creating your first Android view to customizing it to enable it to support any complex app.

Table of contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Errata
      3. Piracy
      4. Questions
  2. Getting Started
    1. What's a custom view
      1. The need for custom views
      2. Examples on the market
    2. Setting up the environment
      1. Installing development tools
      2. How to set up an emulator
      3. How to set up a real device for developing
    3. Creating our own first custom view
      1. Extending a view
      2. Creating a simple view from scratch
    4. Summary
  3. Implementing Your First Custom View
    1. Measuring and parameterizing our custom view
      1. Measuring our custom view
      2. Parameterizing our custom view
    2. Instantiating custom views
      1. Instantiating custom views from code
      2. Builder pattern
    3. Creating a custom layout
      1. Extending ViewGroup
    4. Basic rendering
      1. Creating the basic circular activity indicator
    5. Summary
  4. Handling Events
    1. Basic event handling
      1. Reacting to touch events
      2. Drag events
      3. Complex layouts
    2. Advanced event handling
      1. Detecting gestures
    3. Summary
  5. Advanced 2D Rendering
    1. Drawing operations
      1. Bitmaps
      2. Using the Paint class
      3. Drawing more primitives
      4. Drawing text
      5. Transformations and operations
      6. Putting it all together
    2. Summary
  6. Introducing 3D Custom Views
    1. Introduction to OpenGL ES
      1. Getting started with OpenGL ES in Android
      2. Drawing basic geometry
    2. Drawing geometry
      1. Adding volume
      2. Adding textures
      3. Loading external geometry
    3. Summary
  7. Animations
    1. Custom-made animations
      1. Timed frame animations
      2. Fixed timestep
    2. Using Android SDK Classes
      1. ValueAnimator
      2. ObjectAnimator
    3. Summary
  8. Performance Considerations
    1. Performance impact and recommendations
      1. The impact of not following the best practices
      2. Code optimization
      3. Mocking up the preview window
    2. Summary
  9. Sharing Our Custom View
    1. Best practices for sharing our custom view
      1. Considerations and recommendations
      2. Configurable
    2. Publishing our custom view
      1. Open sourcing our custom view
      2. Creating a binary artifact
    3. Summary
  10. Implementing Your Own EPG
    1. Building an EPG
      1. EPG basics and animation setup
      2. Interaction
      3. Zooming
    2. Configurations and Extensions
      1. Making it configurable
      2. Implementing callbacks
    3. Summary
  11. Building a Charts Component
    1. Building a basic chart custom view
      1. Margins and padding
      2. Basic implementation
      3. Optimizations and improvements with Paths
      4. Background lines and details
      5. Customizations
    2. Adding advanced features
      1. Real-time updates
      2. Multiple data sets
      3. Zooming and scrolling
    3. Summary
  12. Creating a 3D Spinning Wheel Menu
    1. Creating an interactive 3D custom view
      1. Adding interactions
      2. Improving interactions and animations
      3. Adding actionable callbacks
      4. Customizations
    2. Beyond the basic implementation
      1. Rendering text
      2. Multiple faces
    3. Summary

Product information

  • Title: Building Android UIs with Custom Views
  • Author(s): Raimon Ràfols Montané
  • Release date: October 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781785882869