Monthly archives: September, 2016

Supporting Different Densities in Android

This lesson shows you how to support different screen densities by providing different resources and using resolution-independent units of measurements. Use Density-independent Pixels One common pitfall you must avoid when designing your layouts is using absolute pixels to define distances or sizes. Defining layout dimensions with pixels is a problem because different screens have different …

Supporting Different Screen Sizes in Android

This lesson shows you how to support different screen sizes by: Ensuring your layout can be adequately resized to fit the screen Providing appropriate UI layout according to screen configuration Ensuring the correct layout is applied to the correct screen Providing bitmaps that scale correctly Use “wrap_content” and “match_parent” To ensure that your layout is …

Setting Up the App Bar in Android

In its most basic form, the action bar displays the title for the activity on one side and anoverflow menu on the other. Even in this simple form, the app bar provides useful information to the users, and helps to give Android apps a consistent look and feel. Figure 1. An app bar with the …

Adding an Up Action in Android

Your app should make it easy for users to find their way back to the app’s main screen. One simple way to do this is to provide an Up button on the app bar for all activities except the main one. When the user selects the Up button, the app navigates to the parent activity. …

Adding and Handling Actions in Android

The app bar allows you to add buttons for user actions. This feature lets you put the most importantactions for the current context right at the top of the app. For example, a photo browsing app might show share and create album buttons at the top when the user is looking at their photo roll; …

Building and Displaying a Pop-Up Message in Android

You can use a Snackbar to display a brief message to the user. The message automatically goes away after a short period. A Snackbar is ideal for brief messages that the user doesn’t necessarily need to act on. For example, an email app could use a Snackbar to tell the user that the app successfully …

Action Views and Action Providers in Android

The v7 appcompat support library Toolbar provides several different ways for users to interact with your app. Previous lessons described how to define an action, which can be either a button or a menu item. This lesson describes how to add two versatile components: An action view is an action that provides rich functionality within …