如何在具有Holo主题的旧版本上使用Material Theme启动项目?

时间:2014-08-16 11:39:47

标签: android themes android-5.0-lollipop material-design

如何在具有Holo主题的旧版本上使用Mareial Theme启动项目? 我有2个文件夹:值和值-v21。每个这个文件夹都有styles.xml。 值:样式:

 <resources>

        <!-- Base application theme. -->
        <style name="AppTheme" parent="android:Theme.Holo.Light">
            <!-- Customize your theme here. -->
        </style>

    </resources>

Values-v21:styles:

<resources>
    <style name="AppTheme" parent="android:style/Theme.Material.Light">
        <!-- Main theme colors -->
        <!--   your apps branding color (for the app bar) -->
        <item name="android:colorPrimaryDark">@color/primary_dark</item>
        <item name="android:colorPrimary">@color/primary</item>
        <!--   darker variant of colorPrimary (for status bar, contextual app bars) -->
        <!--   theme UI controls like checkboxes and text fields -->
        <item name="android:colorAccent">@color/accent</item>
        <item name="android:navigationBarColor">@color/navigation_bar</item>
    </style>
</resources>

我的build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-L'
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.temdev.yesno"
        minSdkVersion 14
        targetSdkVersion 'L'
        versionCode 1
        versionName "1.15.8"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

1 个答案:

答案 0 :(得分:0)

尝试在<uses-sdk tools:node="replace" />文件中添加AndroidManifest.xml

不要在L中引用android-Lbuild.gradle,而只需使用21

android {
    compileSdkVersion 21
    buildToolsVersion '20.0.0'
    defaultConfig {
        applicationId 'com.temdev.yesno'
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName '1.15.8'
    }
    ...
}