Cody February 2016

Android 5.0(Lollipop): Material Style Not Being Applied

I'm trying to make my app fit with Google's best practices for material design but for some reason the items I set in my v21\styles.xml are never applied to my application.

Please take a look at the v21 styles and Android Manifest files below and tell me what I'm doing wrong that would cause my custom AppTheme to not show up.

v21\styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- android theme colors -->
        <!-- Main theme colors -->
        <!--   your app branding color for the app bar -->
        <item name="colorPrimary">#F44336</item>
        <!--   darker variant for the status bar and contextual app bars -->
        <item name="colorPrimaryDark">#FFD600</item>
        <!--   theme UI controls like checkboxes and text fields -->
        <item name="colorAccent">#FFD600</item>
    </style>
</resources>

AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.foo"
        android:versionCode="1"
        android:versionName="1.0" >

        <uses-sdk
            android:minSdkVersion="12"
            android:targetSdkVersion="23" />

        <application
            android:allowBackup="true"
            android:icon="@drawable/launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme">   **Theme set here**
            <activity
                android:name=".MainActivity"
                android:configChanges="orientation|keyboardHidden|screenSize"
                android:label="@string/app_name"
                android:theme="@style/FullscreenTheme" >
                <intent-filter>
            

Answers


Guilherme P February 2016

I found the error.

Basically, in your Manifest File, you are setting "AppTheme" for application. However, you are also setting a Theme for the activity (FullscreenTheme).

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    ...
    <application
        android:theme="@style/AppTheme">   **Theme set here**
        <activity
            android:theme="@style/FullscreenTheme" >
        ...               
        </activity>
    </application>
</manifest>

To Fix, I see two options:

Option1:

You can remove:

android:theme="@style/FullscreenTheme"

Option2:

If you really need to use that FullscreenTheme, added it to v21/styles.xml. Then, you can set it diferently in v21.

It is your call!

Post Status

Asked in February 2016
Viewed 2,889 times
Voted 10
Answered 1 times

Search




Leave an answer