0
votes

I try to change the background of the action bar using library of google actionbarcompact but i cant thats my code

in the manifest.xml make references to Theme.AppCompat.Light.DarkActionBar thats the theme that show the action bar api level below 10 manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.action"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >

        <activity
            android:name="com.example.action.MainActivity"
            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>

style of the Theme.Base.AppCompat.Light.DarkActionBar the problem is when i used @color/fondoaction change the bakcground color of the layout principal and didnt of the action bar

   <style name="Theme.Base.AppCompat.Light.DarkActionBar"
           parent="android:Theme.Holo.Light.DarkActionBar">
        <!-- Copy system flag values for our use -->

        <!-- <item name="android:background">@color/fondoaction</item>
        <item name="android:textColor">@color/actionletras</item>-->

        <item name="windowActionBar">?android:attr/windowActionBar</item>
        <item name="actionBarSize">?android:attr/actionBarSize</item>
        <item name="actionBarItemBackground">@color/fondoaction</item>
        <item name="selectableItemBackground">?android:attr/selectableItemBackground</item>
        <item name="actionButtonStyle">?android:attr/actionButtonStyle</item>
        <item name="dividerVertical">?android:attr/dividerVertical</item>
        <item name="dividerHorizontal">?android:attr/dividerHorizontal</item>
        <item name="actionBarWidgetTheme">@style/Theme.AppCompat</item>
        <item name="android:actionBarWidgetTheme">?attr/actionBarWidgetTheme</item>

        <!-- Required for use of support_simple_spinner_dropdown_item.xml -->
        <item name="listPreferredItemHeight">?android:attr/listPreferredItemHeight</item>
        <item name="listPreferredItemHeightSmall">?android:attr/listPreferredItemHeightSmall</item>
        <item name="listPreferredItemHeightLarge">?android:attr/listPreferredItemHeightLarge</item>
        <item name="listPreferredItemPaddingLeft">?android:attr/listPreferredItemPaddingLeft</item>
        <item name="listPreferredItemPaddingRight">?android:attr/listPreferredItemPaddingRight
        </item>

        <!-- Attributes populated from the framework to be read by apps -->
        <item name="buttonBarStyle">?android:attr/buttonBarStyle</item>
        <item name="buttonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
    </style>

</resources>
1
Your menu does not have to do anything with your action bar's background.Ahmad
Ahmad I put the manifest.xml where i maked ferences to Theme.AppCompat.Light.DarkActionBar of the library actionbarcompatuser3159679
Ahmad can you helpme please bro i cant change the color of action bar with actionbarcompat i was use theme Theme.Holo.Light.DarkActionBaruser3159679
"Ahmad, please help your brother" - momEmmanuel

1 Answers

0
votes

Menu is the items that go on top of the action bar, you need to set up styles

Add styles XML and create a theme, tell that theme where to look for action bar styles

  <style name="AppTheme" parent="Theme.AppCompat">
      <item name="android:actionBarStyle">@style/MyActionBarTheme</item>
      <item name="actionBarStyle">@style/MyActionBarTheme</item>
      ....
  </style>

Add the action bar theme to the styles xml as well, below the other styles tag

  <style name="MyActionBarTheme" parent="android:Widget.ActionBar">
      <item name="android:background">@drawable/my_background</item>
  </style>

Add your theme to your application in the manifest

  <application ...
      android:theme="@style/AppTheme">