Dheeraj
Dheeraj

Reputation: 105

Custom Material Style not Working

I have an app with min sdk 18 that works fine without the material theme style but when i put a material style in values-v21 the app just crashes as soon as its launched. I've confirmed that this is the cause of the crash.
I've seen solutions for the Holo styles where you have to use the Base.AppCompat.Holo.Dark as a parent. Is there something similar for Material?
I've attached the styles.xml from the values-v21 directory below. Please ask if you need any more info.
Android Studio 1.2 on Windows 8.1 Testing on a OnePlus One

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material">
    <item name="android:colorPrimary">@color/primary</item>
    <item name="android:colorPrimaryDark">@color/primary_dark</item>
    <item name="android:colorAccent">@color/accent</item>
</style>
</resources>

Upvotes: 0

Views: 823

Answers (1)

rahul.ramanujam
rahul.ramanujam

Reputation: 5618

use AppCompat instead of Material

dependencies {
    compile "com.android.support:appcompat-v7:21.0.+"
}

Theme :

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

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

Upvotes: 1

Related Questions