My app's primary color is some kind of yellow. The ShareActionProvider in the action bar has a kind of spinner that when pressed shows the default holo blue color.
To make the action bar style coherent, I need to have the share button background go yellow when pressed. How to achieve that?
I am using the standard action bar (no compatibility or sherlock)
That one does not work:
shareMenuItem.getActionView().setBackgroundResource(R.drawable.spinner_background_ab_webcamhd_custom_ab);
And none of the questions on SO about styling the ShareActionProvider got any answer :(
I added this to my theme and it worked:
So if you want to customize the colors you need to create your own style
I wanted white share button with a white background to popup. So first I changed the textColorSecondary in my main theme to white.
Then I used a custom style for the popup as given by intips' answer:
And then in my toolbar I set this theme:
Doesn't the
ShareActionProvider
use the standard Action Bar background? If so, you can control this by overriding the resource used in your theme. E.g.For an example on how to build the XML Selector Drawable, check out the one used by the system , like this.
Update
How to find this yourself.
SharedActionProvider
and examineonCreateActionView()
.ActivityChooserView
which is theView
created inonCreateActionView()
.ActivityChooserView
, in this caseR.layout.activity_chooser_view
.R.layout.activity_chooser_view
and find the layout used for the button, in this case@+id/expand_activities_button
.android:background="?android:attr/actionBarItemBackground"
For anyone who has the same problem this is what worked for me:
-in AppTheme add:
-create new style for listpopup: