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 and get to the point:

The new material theme provides the following:
1. A system part component that agrees to set the color board is provided.
2. Provides touch feedback animations for these system components.


3. Transition animations for activity.

Depending on your brand identity, you can define the appearance of your material theme using the color palette you control.

Use the properties of the theme to color the Actionbar and status bar.

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

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 only agrees to be used on Android 5.0 and above systems. V7 's support library (V7 supports libraries) provides some components with themes for material design styles, and also enables you to define color palettes. For details, see: Guaranteed Compatibility

Define your own color palette

To define your own theme base color for your brand, use theme attributes to define your own color 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>
Define the status bar yourself

The material theme makes it easy to define the status bar yourself, so you can specify a color that fits your brand, making the white status bar icon more visually contrasting. When you inherit the material theme, you want to define 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 content 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 the @android: Color/transparent and on-need basis. You can also use Window.setstatusbarcolor () to animate or retreat.

Note: the status bar and the main toolbar should have a clear definition. In addition to the status bar to display pictures or multimedia-related content, use the gradient to ensure that the status bar icon is still visible.
When you define the navigation bar and the status bar, just let the status bar change or adjust the transparency.

In other cases, the navigation bar remains black.

To 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 changes the subject of the element and child elements. is to change the color palette of its theme in part of a specified interface.

The above translation of the content of the external links in the future will be gradually translated out, the current link is the official site, if you need to see friends, please first FQ.

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

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.