Android (Lollipop/5.0) Material Design (7) Compatibility

Source: Internet
Author: User
Tags xml attribute

Android (Lollipop/5.0) Material Design (7) Compatibility
Define Alternative Styles defines Alternative Styles for your app to run theme with Material Design on devices that support it, and can run earlier theme on devices of earlier versions: 1. in res/values/styles. xml defines a topic to inherit an earlier Topic 2. in res/values-v21/styles. xml defines a theme with the same name inherited from the Material Topic 3. apply a defined topic in manifest. Note: If your app uses a Material topic and does not provide an earlier topic, it cannot run on a device of an earlier version.
Provide Alternative Layouts provides Alternative layout S. If the layout you designed does not reference any xml Attribute in 5.0, it can run on earlier Android devices. Otherwise, you can provide an alternative layout. Alternative la s are built on res/layout-v21/to avoid repeated code, you can define your styles in res/values/, the new style is defined in res/values-21, use style inheritance to define a baseStyle IN res/values and inherit it from res/values-21.
Use the Support Library v7 support library includes the following features. after the AppCompat topic, some components of the system have the Material Design style. in the AppCompat topic, there is a color theme. The RecyclerView component displays the dataset. The CardView component creates a card and obtains the color from the image.
System widgets System component Theme. AppCompat topic provides Material Design-style components:
· EditText · Spinner · CheckBox · Radiobutton · SwitchCompat · CheckedTextView
Color Palette uses the v7 support library to obtain the Material Design style definition Color Palette and apply a Theme. AppCompat topic:

 

After Lists and Cards use the v7 support library, they can also run in earlier Android versions.
Dependenciesgradle dependency:
dependencies {    compile 'com.android.support:appcompat-v7:21.0.+'    compile 'com.android.support:cardview-v7:21.0.+'    compile 'com.android.support:recyclerview-v7:21.0.+'}
Check the System Version to Check the System Version
The following features can only be found in Android 5.0 (API level 21) and later versions:
· Activity transitions Activity Conversion
· Touch feedback tactile feedback
· Reveal animations display Animation
· Path-based animation based on Path
· Vector drawables Vector image

· Drawable tinting image Dyeing

Check Code:

// Check if we're running on Android 5.0 or higherif (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {    // Call some material design APIs here} else {    // Implement this feature without material design}
Note: To make the app support 5.0, Android: targetSdkVersion = 21 in manifest.








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.