0

I spend 3 days looking and serching for solution how to change the Action bar icon depending on what theme is used in theme.xml.

My first attempt how to achieve this was to bring ?attr/attribute to AndroidManifest.xml, but soon I realize this is not possible.

So than I was playing around style.xml and theme.xml file. I found this solution on SO. This is ok, but the icon does not appear...

I want it to appear exactly as when I set android:logo="@drawable/logo" in AndroidManifest.xml(so in left corner).

My code in theme.xml:

<style name="Theme" parent="android:Theme.Holo">
   <item name="android:actionBarStyle">@style/actionBar</item>
</style>

<style name="actionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:displayOptions">showTitle</item>
    <item name="customSearchIcon">@drawable/logo</item> 
</style>

My menu/login.xml file:

<item
    android:id="@+id/logo"
    android:icon="?attr/customSearchIcon"
    android:title="@string/settings"/>

EDIT: The problem -> 1) Why this is not working - android:icon="?attr/customSearchIcon" ? 2) How to set the icon exactly in the same position like when you set icon in AndroidManifest.xml by android:logo="@drawable/logo" (so in left corner).

Do you have any ideas?

Community
  • 1
  • 1
kristyna
  • 1,360
  • 2
  • 24
  • 41

0 Answers0