Use Material Design to create an app translation series----material themes (using Material Theme)

Source: Internet
Author: User

The previous article was to create an app translation series using material Design--start learning the article and get to the point:

The new material theme provides the following:
1. A system part component that allows the setting of the color palette is provided.
2. Provides touch feedback animations for these system components.
3. Transition animations for activity.

Depending on your brand identity, you can customize the appearance of the material theme using the color palette you control. Use the properties of the theme to color the Actionbar and the status bar.

The system components have new design and touch feedback animations. You can customize the color palette for your app, touch feedback animations, and transition animations for jumps between activity.

Here's how the material theme is defined:
1. @android: style/theme.material (Dark Version)
2. @android: Style/theme.material.light (Light version)
3. @android: Style/theme.material.light.darkactionbar
You can use the above several material theme styles, referenced in the way visible in R.style.


Dark Material Theme

Light Material Theme

Note : This material theme is only allowed on Android 5.0 and above system use. V7 's support library (V7 supports libraries) provides some components with themes for material design styles, and also supports custom color palettes. For details, see: Guaranteed Compatibility

Custom color palettes

To customize the theme base color for your brand, use theme properties to define your custom colors when inheriting material themes:

<resources> <!--inherit from the material theme to <style name="Apptheme"Parent="Android:Theme.Material"> <!--Main Theme Colors--<!--your app branding color forThe app Bar--<item name="Android:colorprimary">@color/primary</item> <!--Darker variant forThe status bar and contextual app bars--<item name="Android:colorprimarydark">@color/primary_dark</item> <!--theme UI controls like checkboxes and text fields--and <item name="Android:coloraccent">@color/accent</item> </style></resources>
Customizing the status bar

Material themes make it easy to customize the status bar, so you can specify a color that fits your brand, making the white status bar icon more contrasting. If you inherit the material theme, you want to customize the color of the status bar, use the Android:statusbarcolor property. By default, Android:statusbarcolor property values are inherited from Android:colorprimarydark.

You can also draw the contents behind the status bar. For example, if you want to display a photo under a transparent status bar, use a slightly darker transition color to make sure that the White status bar icon is visible. Adjust the windowflags by setting the value of the Android:statusbarcolor property to @android: Color/transparent and as needed. You can also use Window.setstatusbarcolor () to animate or retire.

Note: the status bar and the main toolbar should have a clear definition, in addition to the status bar after the display of pictures or multimedia-related content, in the use of gradient to ensure that the status bar icon is still visible.
When customizing the navigation bar and status bar, just let the status bar be modified or adjusted for transparency. In other cases, the navigation bar remains black.

Add a theme to an individual view control

Controls defined in the XML layout need to specify the Android:theme property to reference the theme resource. This property modifies the theme of the element and child elements, and is intended to change the color palette of its theme in a specified part of the interface.

The above translation content in the external link of the part, will be gradually translated, the current link is the official website, if you need to see the friends, please first turn over the wall.

Use Material Design to create an app translation series----material theme usage (using Material Theme)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.