Android ShareActionProvider DarkActionBar Fix

Fri, Nov 15, 2013 One-minute read

With the beta of the Droidcon NL 2013 app Quirijn Groot Bluemink posted a screenshot which showed a small problem; The menu provided by ShareActionProvider as part of the Theme.AppCompat.Light.DarkActionBar has black text on a dark grey background.

Screenshot of problem

The problem is due to the layout for each item in the menu defined in abc_activity_chooser_view_list_item.xml. The TextView in the layout uses ?attr/textAppearanceLargePopupMenu, which, when you follow the references all the way down to TextAppearance.AppCompat.Base.Widget.PopupMenu.Large has the definition;


In the Light themes textColorPrimaryDisableOnly ends up, after a few references, being defined as;


which is where the black text comes from.

Did I fix the problem? Yes. Am I proud of the fix? No. My focus was on getting the application complete and working, and in order to do that the most time-efficient route was to import all the source code and resources for the appcompat library into the project and alter the TextView in abc_activity_chooser_view_list_item.xml to use a local style with the following definition;

    <style name="TextAppearance.ShareList"
        <item name="android:textColor">@android:color/white</item>
        <item name="android:textSize">18sp</item>

I can only hope that Google will get one of their legion of engineers to create something a bit more manageable in the next release of the support libraries.