ShareActionProvider menu style

1000 views Asked by At

I have this menu when the user clicks on the ShareActionProvider: enter image description here

How can I change its background color. I suppose I have to style it but I cannot find anywhere how.

2

There are 2 answers

0
Raul Pinto On

So, what I did to style it was edit our styles.xml.

<!-- ACTION BAR -->
<style name="ToolbarTheme">
    <item name="android:textColorPrimary">#fff</item>
    <item name="colorControlNormal">#fff</item>
    <item name="colorControlHighlight">#3fff</item>
    <item name="android:listPopupWindowStyle">@style/ToolbarPopupListStyle</item>
    <item name="listPopupWindowStyle">@style/ToolbarPopupListStyle</item>
    <item name="android:textAppearanceLargePopupMenu">@style/PopupMenuTextAppearance</item>
    <item name="textAppearanceLargePopupMenu">@style/PopupMenuTextAppearance</item>
</style>
<style name="ToolbarStyle">
    <item name="android:background">?colorPrimary</item>
    <item name="android:titleTextAppearance">@style/collapsedToolbarText</item>
    <item name="titleTextAppearance">@style/collapsedToolbarText</item>
</style>

<style name="ToolbarPopupListStyle">
    <item name="android:popupBackground">#00ff00</item>
</style>
<style name="PopupMenuTextAppearance" parent="android:TextAppearance.Small">
    <item name="android:textColor">#ff0000</item>
</style>

Of course, these styles have to be referenced in the layout file where Toolbar is referenced:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@android:color/transparent"
    app:layout_collapseMode="pin"
    app:theme="@style/ToolbarTheme"
    style="@style/ToolbarStyle"/>

I have the weird feeling, though, that styles should have a parent style. But it works out like this.

Thanks to @Brian who pointed me in the right direction.

0
Brian On

You might want to take a look at the source code, if there is no documentation on how to apply a style. I haven't actually tried to style the ShareActionProvider, but I got quite some clues from the code:

  1. ShareActionProvider.java is probably responsible in the first place
  2. ActivityChooserView.java looks like the used view class which leads to ...
  3. abc_activity_chooser_view.xml is most likely the used view, which has ?attr/activityChooserViewStyle applied as the style reference
  4. looking into themes.xml yields in line 75:

    <item name="activityChooserViewStyle">@style/Widget.AppCompat.ActivityChooserView</item>
    

Would love to hear if this works, as I might be in the same situation soon ;)