Implement material design applications on low-version Android systems

Source: Internet
Author: User

Material design really looks good, the animation effect is really very practical. I also wrote some articles about how to write material-style programs, but a lot of them are new APIs, and the lower version doesn't have these APIs, and we can't use them. But don't be discouraged, Google official, and some Daniel, to provide us with some procedures, let us in the lower version can implement the material style of the program, here to introduce you.

Sister picture screenshot

Using the Support library

Using the latest version of the support library, appcomt21, can be implemented in the lower version of some of the style, in the previous article I have said, here in the system to say.

Apply Theme

This part of the words before the article said that the link is here: http://blog.isming.me/2014/10/18/creating-android-app-with-material-design-one-theme/

To build with Gralde, add the V7 package to the 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.+ '
}

Also add in the style file: build with Eclipse and add the latest AppCompat package.

<style name= "Theme.mytheme" parent= "Theme.AppCompat.Light" >
<!--Customize the color palette --
<item name= "colorprimary" > @color/material_blue_500</item>
<item name= "Colorprimarydark" > @color/material_blue_700</item>
<item name= "coloraccent" > @color/material_green_a200</item>
</style>

Use toolbar instead of Actionbar. Using our theme.mytheme in Appliaction, there was an error in the last article, in which case it is not necessary to create a theme with the same name in Valus-v21 that inherits from material. So we can use the material style. However, there are still many places in the lower version that can not achieve this effect.

Android 5.0 adds toolbar, which can be used instead of Actionbar, and is recommended in lower versions, so that animation effects are easier to implement.

Add toolbar to the layout file:

<android.support.v7.widget.toolbar
Xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:id= "@+id/toolbar"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
Android:background= "? Attr/colorprimarydark"/>

@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (Getlayoutresource ());
Toolbar Toolbar = (Toolbar) Findviewbyid (R.id.toolbar);
if (Toolbar! = null) {
Setsupportactionbar (toolbar);
}
}

In code, use toolbar instead of Actionbar (activity must be inherited from Actionbaractivity):

Using CardView

I don't know, see my previous blog http://blog.isming.me/2014/10/21/creating-app-with-material-design-two-list/.

Using animations

For the low version, there are some compatibility in the support V7 package, which can be animated with activity transitions (although the effect is not 5.0 good).

When you first declare a theme, create a apptheme.base that declares the theme and adds animation properties to it:

The following is placed in the values/themes.xml to fit the lower version:

<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
<style name= "Apptheme" parent= "Apptheme.base"/>
< style name= "Apptheme. Base "Parent=" Theme. AppCompat ">
< item name= "Colorprimary" > @color/colorprimary</item>
<item name= "Colorprimarydark" > @color/colorprimary</item>
<item name= "Android:windownotitle" >true</item>
<item name= "Windowactionbar" >false</item>
</style>
</resources>

<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
<style name= "Apptheme" parent= "Apptheme.base" >
< item name= "Android:windowcontenttransitions" > true</item>
< item name= "Android:windowallowentertransitionoverlap" > true</item>
< item name= "Android:windowallowreturntransitionoverlap" > true</item>
< item name= "Android:windowsharedelemententertransition" > @android:transition/move</item>
<item name= "Android:windowsharedelementexittransition" > @android:transition/move</item>
</style>
</resources>


The following are placed in the Values-v21/themes.xml

When starting a new activity in code, use the method in the V7 package, as in 5.0, you can see my previous blog:

Activityoptionscompat options = Activityoptionscompat.makescenetransitionanimation (
Activity, Transitionview, detailactivity.extra_image);
Activitycompat.startactivity (activity, new Intent (activity, Detailactivity.class),
Options.tobundle ());

For many of the control styles, animations, dialogs, etc., using the Compatibility Pack cannot be done, we can use some of the great God developed third-party packages to achieve.Using Open Source Controls

Component: Https://github.com/navasmdc/MaterialDesignLibrary

Https://github.com/keithellis/MaterialWidget

The above two are mainly components that implement the material

Material Design dialog box: https://github.com/afollestad/material-dialogs

This github repository collects a lot of open source implementations and you can come and see. Https://github.com/lightSky/MaterialDesignCenter

Other

According to the specifications provided, to implement the corresponding UI interface and animation effects and so on.
Here is a Google's canonical address:
Google Design code: http://www.google.com/design/spec/material-design/introduction.html need to turn the wall, http://design.1sters.com (Chinese)

Icon Material: https://github.com/google/material-design-icons, https://github.com/Templarian/MaterialDesign

Google io2014,material Design interpretation: https://github.com/google/iosched

Applications written by other people: https://github.com/afollestad/cabinet

I write an application, from the previous version of the change, has not finished, you can just look at the line, but also material design:https://github.com/sangmingming/meizitu

Original address: Http://blog.isming.me/2014/11/17/material-design-for-pre-lollipop-android/, reproduced please indicate the source.

Implement material design applications on low-version Android systems

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.