Search code examples
androidandroid-intentandroid-actionbarandroid-stylesandroid-sharing

Android ShareActionProvider Set Text Color


Is there a style that works with the Android ShareActionProvider that allows the text to be white instead of black. I have tried:

<item name="android:textColor">@android:color/white</item>
<item name="android:itemTextAppearance">@style/menu_color</item>
<item name="android:textAppearanceListItem">@style/menu_color</item>
<item name="android:textAppearanceListItemSmall">@style/menu_color</item>
<item name="android:textAppearanceLarge">@style/menu_color</item>`
<item name="android:textAppearanceLargePopupMenu">@style/MyShareActionProviderStyle</item>`
<item name="android:textAppearanceSmallPopupMenu">@style/MyShareActionProviderStyle</item>`
<item name="android:actionMenuTextAppearance">@style/share_item_color</item>

I have tried all of these properties in a number of different configurations and cannot seem to find the right property to change to get the text to be the correct color.

I am using a Holo theme base and I am not using AppCompat or ActionBarSherlock. Thanks for your help in advance.


Solution

  • Here is what I ended up doing:

    First I created a subclass of ShareActionProvider and set that in the menu xml file for that fragment as the android:actionProviderClass

    Then in the onCreateActionView of that ShareActionProvider subclass i did this:

    View v = super.onCreateActionView();
    for(int i=0; i<((ViewGroup)v).getChildCount(); ++i) {
        View nextChild = ((ViewGroup)v).getChildAt(i);
        TextView title = (TextView)nextChild.findViewById(android.R.id.title);
        if(title != null){
            title.setTextColor(Color.WHITE);
        }
    }
    return v;
    

    That got me the text of the menu white like I needed. Hope this helps someone in the future.