Preface
User interfaces represent the single most important aspect of any modern mobile application. They are the primary point of contact with your user, and a good user interface can be the difference between the success and failure of an application. This book will guide you down the path of user interface excellence, teaching you the techniques of great user interface design for Android, and showing you how to implement them.
Building user interfaces is all about building for the user and making their lives easier. It's important that the user interface helps the user achieve their goals within the application without distracting them. This means that each screen must serve a purpose, and every widget must work for its place on the screen. Widgets that are seldom used are distractions and should be moved, or removed, from the application entirely.
User interfaces are not just about pretty colors, fonts, and graphics; they are at the heart of the user experience within an application. How you create your user interfaces is built on the underlying structures you build in your applications code base. If the foundations of the application are not solid, the user experience will suffer. Every action taken by the user should have a quick and positive result, reinforcing their confidence that they can reach their goals within the application.
In this book, we'll be exploring not just how to write user interface code, but how to go about designing great user interfaces as well. We'll look at how lower layers like data storage can impact the user experience, and how to leverage the Android platform and its support libraries to build better applications, applications that look great, run fast, and help ensure that the user can understand the application quickly and is guided through with minimal distractions.
What this book covers
Chapter 1, Creating Android Layouts, will introduce or reintroduce Android Studio and help create a new Android application project from a template. We'll look at how an Android project is structured and how a user interface is wired together.
Chapter 2, Designing Form Screens, will show you how to design a form screen from scratch. You will learn techniques to decide what to put on the screen and how to layout a form screen to maximize its effectiveness while not disrupting your user's flow of thought.
Chapter 3, Taking Actions, will show you how to handle events in Android. It'll walk you through various types of events and provide you patterns and techniques to keep your application as responsive as possible. It'll also show you techniques to avoid complexity overload in your code base and how to keep your application's internal structure as clean as possible.
Chapter 4, Composing User Interfaces, will give you tools to build modular user interface components. It'll show you how to wrap related logic and user interface structures so that they can be reused, to reduce your code complexity while also making the user experience more consistent.
Chapter 5, Binding Data to Widgets, will introduce the data binding framework in Android. You'll find out why data binding exists, how it works, and how to use it effectively. You'll learn how to create user interface structures that automatically update when the data model changes.
Chapter 6, Storing and Retrieving Data, will cover how the storage and retrieval of data in a mobile app has a direct effect on the user experience. You will learn how best to build offline-first, reactive applications using the Room data access layer and data binding.
Chapter 7, Creating Overview Screens, will explore the RecyclerView
and how it is often used in overview screens and dashboards to provide information. You'll learn how to create the data structures that support a RecyclerView
and how to leverage data binding to massively reduce the boilerplate traditionally associated with these structures.
Chapter 8, Designing Material Layouts, will introduce several Material Design-specific patterns and widgets for Android apps. You'll learn how to leverage collapsing title bars and customize them to show your user additional information. You'll also learn how to add swipe-to-dismiss behavior, undo snackbars, and elevation to your user interfaces.
Chapter 9, Navigating Effectively, will help you learn to make a design-effective application navigation to guide your user to their intended goals intuitively. This chapter introduces several navigation-specific widgets and layout techniques, and shows where and how they can be most effectively applied.
Chapter 10, Making Overviews Even Better, will revisit the overview screen built in Chapter 7, Creating Overview Screens, and show how to leverage the Android platform API to produce polished overview screens. You'll learn how to use DiffUtil
to automatically produce animations in RecyclerView
and patterns that allow you to produce more readable overview lists.
Chapter 11, Polishing Your Design, will help you with the polishing of a good design. It'll introduce tools and techniques to help you choose a color scheme for your application. You'll also learn how to generate color schemes on the fly and how to create and use animations to guide your users.
Chapter 12, Customizing Widgets and Layouts, will introduce building your own custom widgets for Android. You'll learn how to render 2D graphics directly from Java code and how to create your own custom layouts. This chapter also shows how to build animation widgets that self-animate while they are visible.
Appendix A, Activity Lifecycle, a diagram and short description covering the lifecycle events delivered to an Android Activity
, and when they can be delivered.
Appendix B, Test Your Knowledge Answers, the answers to the Test Your Knowledge section of each chapter.
What you need for this book
You'll need to download and install at least Android Studio 3.0. Using Android Studio, you will need to download a recent Android SDK so that you can compile and run your code.
Who this book is for
This book is for novice Android and Java developers who have basic knowledge of Android development and want to start developing stunning user interfaces.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning. Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The next lines of code read the link and assign it to the constantSize
attribute." A block of code is set as follows:
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:constantSize="true" android:exitFadeDuration="@android:integer/config_shortAnimTime" android:enterFadeDuration="@android:integer/config_shortAnimTime">
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
<selector
xmlns:android="http://schemas.android.com/apk/res/android"
android:constantSize="true"
android:exitFadeDuration="@android:integer/config_shortAnimTime"
android:enterFadeDuration="@android:integer/config_shortAnimTime">
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "In order to download new modules, we will go to Files
| Settings
| Project Name
| Project Interpreter
."
Note
Warnings or important notes appear like this.
Note
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply email [email protected]
, and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files emailed directly to you. You can download the code files by following these steps:
- Log in or register to our website using your email address and password.
- Hover the mouse pointer on the
SUPPORT
tab at the top. - Click on
Code Downloads & Errata
. - Enter the name of the book in the
Search
box. - Select the book for which you're looking to download the code files.
- Choose from the drop-down menu where you purchased this book from.
- Click on
Code Download
.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
- WinRAR / 7-Zip for Windows
- Zipeg / iZip / UnRarX for Mac
- 7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-Android-UI-Development. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title. To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata
section.
Piracy
Piracy of copyrighted material on the internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at [email protected]
with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at [email protected]
, and we will do our best to address the problem.