2015-06-07 2 views
-1

Согласно этой странице http://developer.android.com/training/material/theme.html#ColorPaletteандроид Lollipop основной цвет не меняется

я могу изменить свои действия бар цвета, изменяя основные цвета.

<resources> 
<!-- your theme inherits from the material theme --> 
<style name="AppTheme" parent="android:Theme.Material"> 
     <item name="android:colorPrimary">#ff9688</item> 
     <!-- darker variant for the status bar and contextual app bars --> 
     <item name="android:colorPrimaryDark">#00796B</item> 
     <!-- theme UI controls like checkboxes and text fields --> 
     <item name="android:colorAccent">#8BC34A</item> 
    </style> 
</resources> 

Однако вставка этого в мой файл styles.xml не влияет на панель действий.

+1

Проверьте свой манифест. Вы придавали стиль вашему заявлению/деятельности? –

+0

Спасибо! это был пролема – in4001

+0

отлично! ... принять ниже заданный ответ от CommonsWare, чтобы он мог помочь другим. –

ответ

0

Вам необходимо убедиться, что ваш манифест использует эту тему.

Например, this sample project применяет пользовательские оттенки к панели действий Theme.Material. Она имеет тему, аналогичную вашей, хотя я тяну мои цвета из в цветовые ресурсы:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <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> 

Тогда в моем манифесте, я применить тему с помощью атрибута android:theme в <application> элемент в манифесте:

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

    <supports-screens 
     android:anyDensity="true" 
     android:largeScreens="true" 
     android:normalScreens="true" 
     android:smallScreens="true"/> 

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

    <application 
     android:allowBackup="false" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme"> 
     <activity 
      android:name="ActionBarDemoActivity" 
      android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN"/> 

       <category android:name="android.intent.category.LAUNCHER"/> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 
Смежные вопросы