ShareActionProvider menu style
Asked Answered
T

2

7

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.

Twinge answered 12/9, 2013 at 12:28 Comment(0)
L
3

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 ;)

Luftwaffe answered 15/11, 2013 at 14:51 Comment(0)
M
0

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.

Monmouth answered 14/12, 2015 at 10:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.