标签:android l material design api
转载请注明 http://blog.csdn.net/eclipsexys 翻译自Developer Android,时间仓促,有翻译问题请留言指出,谢谢
如material design和自定义活动的过渡部分材料设计功能只能在Android5.0(API等级21)以上。不过,你可以设计你的应用程序在支持材料设计,仍然与设备运行的是Android的早期版本兼容的设备上运行。
res/values/styles.xml下。res/values-v21/styles.xml中定义与继承材料主题同名的主题。 res/layout-v21/和你选择的布局文件中的res/layout/早期版本的Android。例如,res/layout/my_activity.xml是es/layout-v21/my_activity.xml另一种布局。 res/values-v21/使用新的API和使用风格的继承,限定在基本样式res/values/和那些继承res/values-v21/。 该Theme.AppCompat主题提供材料的设计风格于:
    EditText
    Spinner
    CheckBox
    RadioButton
    SwitchCompat
    CheckedTextView
为了获得材料的设计风格和自定义调色板与Android V7支持库,应用的Theme.AppCompat主题:
<!-- extend one of the Theme.AppCompat themes -->
<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>dependencies {
    compile ‘com.android.support:appcompat-v7:+‘
    compile ‘com.android.support:cardview-v7:+‘
    compile ‘com.android.support:recyclerview-v7:+‘
}以下功能仅适用于Android的5.0(API等级21)以上: 
    Activity transitions
    Touch feedback
    Reveal animations
    Path-based animations
    Vector drawables
    Drawable tinting
为了保持与早期版本的Android的兼容性,在运行时调用的API来检查系统版本:
// Check if we‘re running on Android 5.0 or higher
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    // Call some material design APIs here
} else {
    // Implement this feature without material design
}Creating Apps With Material Design —— Maintaining Compatibility
标签:android l material design api
原文地址:http://blog.csdn.net/eclipsexys/article/details/40297643