2014-11-05 73 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> 

你还没有把风格标签 “父”。你可以尝试一下 !