简体   繁体   中英

How to launch project with Material Theme on older versions with Holo theme?

How to launch project with Mareial Theme on older versions with Holo theme? I have 2 folder: values and values-v21. Every this folder have styles.xml. Values: styles:

 <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>

My 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'])
}

Try adding <uses-sdk tools:node="replace" /> in your AndroidManifest.xml file.

Instead of referencing L or android-L in your build.gradle , just use 21 :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM