Material Design Features
This topic describes Designer features that make it easier for developers to create Material Design-compliant layouts. This section introduces and explains how to use the Material Grid, the Material Color Palette, the Typographic Scale, and the Theme Editor.
Evolve 2016: Everyone Can Create Beautiful Apps with Material Design
The Xamarin.Android Designer includes features that make it easier for you to create Material-Design-compliant layouts. If you are not familiar with Material Design, see the Material Design Introduction.
In this guide, we'll have a look at the following Designer features:
Material Grid – An overlay on the Design Surface that shows a grid, spacing, and keylines to help you place layout widgets according to Material Design guidelines.
Material Color Palette – A Property Pad dialog that assists you in choosing a color from the official Material Design palette.
Typographic Scale – A Property Pad dialog that provides you with a choice of Material Design-compliant settings for the
textAppearanceproperty of text fields.
Theme Editor – A small color resource editor that lets you set color information for a subset of a theme. For example, you can preview and modify Material colors such as
We'll have look at each of these features and provide examples of how to use them.
Material Design Grid
The Material Design Grid menu is available from the toolbar at the top of the Designer:
When you click the Material Design Grid icon, the Designer displays an overlay on the Design Surface that includes the following elements:
Keylines (orange lines)
Spacing (green areas)
A grid (blue lines)
These elements can be seen in the followng screenshot:
Each of these overlay items is configurable. When you click the
ellipsis next to the Material Design Grid menu, a dialog popover opens
that allows you to disable/enable the grid, configure the placement of
keylines, and set the spacings. Note that all values are expressed in
dp (density-independent pixels):
To add a new keyline, enter a new offset value in the Offset box, select a location (left, top, right, or bottom) and click the + icon to add the new keyline.
Similarly, to add a new spacing, enter the size and offset (in dp) into the Size and Offset boxes, respectively. Select a location (left, top, right, or bottom) and click the + icon to add the new spacing.
When you change these configuration values, they are saved in the layout XML file and reused when you open the layout again.
The Theme Editor lets you customize color information for a subset of theme attributes. To open the Theme Editor, click the paintbrush icon on the toolbar:
Although the Theme Editor is accessible from the toolbar for all target Android versions and API levels, only a subset of the capabilities described below are available if the target API level is earlier than API 21 (Android 5.0 Lollipop).
The left-hand panel of the Theme Editor displays the list of
colors that make up the currently selected theme (in this example,
we are using the
When you select a color on the left, the right-hand panel provides the following tabs to help you edit that color:
Inherit – Displays a style inheritance diagram for the selected color and lists the resolved color and color code assigned to that theme color.
Color Picker – Lets you change the selected to color to any arbitrary value.
Material Palette – Lets you change the selected to color to a value that conforms to Material Design.
Resources – Lets you change the selected to color to one of the other existing color resources in the theme.
Let's look at each one of these tabs in detail.
As seen in the following example, the Inherit tab lists the style inheritance for the Background color of the Default Theme:
In this example, the Default Theme inherits from a style that uses
@color/background_material_dark but overrides it with
color/material_grey_850, which has a color code value of
For more information about style inheritance, see
Styles and Themes.
The following screenshot illustrates the Color Picker:
In this example, the Background color can be changed to any value through various means:
- Clicking a color directly.
- Entering hue, saturation, and brightness values.
- Entering RGB (red, green, blue) values in decimal.
- Setting the alpha (opacity) for the selected color.
- Entering the hexadecimal color code directly.
The color you choose in the Color Picker is not restricted to Material Design guidelines or to the set of available color resources.
The Resources tab offers a list of color resources that are already present in the theme:
Using the Resources tab constrains your choices to this list of colors. Keep in mind that if you choose a color resource that is already assigned to another part of the theme, two adjacent elements of the UI may "run together" (because they have the same color) and become difficult for the user to distinguish.
The Material Palette tab opens the Material Design Color Palette. Choosing a color value from this palette constrains your color choice so that it is consistent with Material Design guidelines.
The top of the color palette displays primary Material Design colors
while the bottom of the palette displays a range of hues for the
selected primary color. For example, when you select Indigo, a
collection of Indigo hues is displayed at the bottom of the dialog.
When you select a hue, the color of the property is changed to the
selected hue. In the following example, the
Background Tint of the
button is changed to Indigo 500:
Background Tint is set to the color code for Indigo 500
#ff3f51b5), and the Designer updates the background color to reflect
For more information about the Material Design color palette, see the Material Design Color Palette Guide.
Creating a New Theme
In the following example, we'll use the Material Palette to create a new custom theme. First, we'll change the Background color to Blue 900:
When a color resource is changed, a message pops up with the message, The current theme has unsaved changes:
The Background color in the Designer has changed to the new color selection, but this change has not yet been saved. Two choices are offered for how to handle the change:
Discard Changes – Discards the new color choice (or choices) and reverts the theme to its original state.
Create New Theme – Creates a new theme that is derived from the currently-selected theme and uses the color overrides made in the Theme Editor.
When you click Create New Theme, one of the following will happen, depending on the selected theme:
If the currently selected theme on the Designer is not a project theme, you are presented with the option to create a new resource file with the customized theme (using the selected theme as the parent of the customized theme). The Designer switches to the customized theme after it is created.
If the currently selected theme is a project theme that is defined in one location, you are presented with the Update theme option; clicking this option updates the currently selected theme rather than creating a new one.
If the currently selected theme is a project theme that is defined in multiple locations (for example, in differently-suffixed values folders such as values-v21), you are presented a dialog that asks for a new location for saving the customized theme.
Continuing the previous example, clicking Create New Theme results in the creation of a new theme called Custom:
Because the currently-selected theme is not a project theme, there is no dialog to update the selected theme or to specify a new location.
This topic described the Material Design features available in the Xamarin.Android Designer. It explained how to enable and configure the Material Design Grid, how to use the Material Design Color Palette to edit color properties, and how to use the Typographic Scale selector to configure text properties. It also demonstrated how to use the Theme Editor to create new custom themes that conform to Material Design guidelines. For more information about Xamarin.Android support for Material Design, see Material Theme.