2014-11-05 74 views
0

我設置顏色爲白色,但它不會改變: activity_my.xml:更改android動作欄顏色?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    tools:context=".MyActivity" 
    android:theme="@style/AppTheme"> 

</RelativeLayout> 

style.xml

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"> 
     <item name="android:actionBarStyle">@style/ActionBar</item> 
    </style> 
    <style name="ActionBar"> 
     <item name="android:background">#ffffff</item> 
    </style> 
</resources> 

AndroidManifest.xml中

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="eu.test.test.test" > 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name=".MyActivity" 
      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> 

我已經搜索,但到處都是這樣解釋。

我已經添加了androidmanifest文件。

+0

ActionBar bar = getActionBar(); bar.setBackgroundDrawable(new ColorDrawable(「COLOR」)); – 2014-11-05 11:14:41

+0

它返回的錯誤不能應用於此顏色 - #ffffff或rgb變體。 – emanuilov 2014-11-05 11:18:59

+0

使用sharelack活動對簡單活動 – 2014-11-05 11:20:30

回答

0

不要忘記使用你創造了AndroidManifest作爲一個應用/活動主題(在relative layoutAppTheme

實例將自己的應用主題:

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
+0

它被添加到那裏。 – emanuilov 2014-11-05 11:15:48

+0

您是否從相對佈局中刪除了android:theme =「@ style/AppTheme」? – 2014-11-05 11:17:49

+0

它不會改變它的顏色。 – emanuilov 2014-11-05 11:20:40

0
<style name="AppTheme" parent="android:style/Theme.Holo.Light.DarkActionBar"> 
    <item name="android:actionBarStyle">@style/ActionBar</item> 
    </style> 
<style name="ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar"> 
    <item name="android:background">@color/dark_grey</item> 
</style> 

你還沒有把風格標籤 「父」。你可以嘗試一下 !