Android API级别21向后兼容?(自SDK新版本发布以来)

Uch*_*iha 6 xml android build material-design android-5.0-lollipop

我遇到API级别21的问题.我想使用Material Design,但仍然可以在较低的API级别(如18(Android 4.3.1))上运行该应用程序.但我总是得到那个错误:在此输入图像描述

我的清单SDK看起来像这样:

在此输入图像描述

和build.gradle一样: 在此输入图像描述

希望这是获得一些帮助的信息,我真的需要它:(

干杯.

Gab*_*tti 8

如doc:https: //developer.android.com/training/material/theme.html中所述

注意:材料主题仅适用于Android 5.0(API级别21)及更高版本

这意味着您必须使用材质主题的values-v21文件夹.

但是,您可以使用v7支持库为某些小部件提供主题和材质设计样式.这是一个使用AppCompat主题的示例.

<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">  
    <!-- Here we setting appcompat’s actionBarStyle -->
    <item name="actionBarStyle">@style/MyActionBarStyle</item>

    <!-- ...and here we setting appcompat’s color theming attrs -->
    <item name="colorPrimary">@color/my_awesome_red</item>
    <item name="colorPrimaryDark">@color/my_awesome_darker_red</item>

    <!-- The rest of your attributes -->
</style> 
Run Code Online (Sandbox Code Playgroud)

更多信息:https: //chris.banes.me/2014/10/17/appcompat-v21/