【问题标题】:How to launch project with Material Theme on older versions with Holo theme?如何在具有 Holo 主题的旧版本上启动具有 Material Theme 的项目?
【发布时间】:2014-10-09 23:29:38
【问题描述】:

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

 <resources>

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

    </resources>

Values-v21:样式:

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

【问题讨论】:

  • 究竟是什么问题,布局没有按预期显示?

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


【解决方案1】:

尝试在您的AndroidManifest.xml 文件中添加&lt;uses-sdk tools:node="replace" /&gt;

不要在build.gradle 中引用Landroid-L,只需使用21

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-04
    相关资源
    最近更新 更多