I think this is related to proguard; please see edits at bottom of post.
I'm using eclipse to build a little android app.
When I run my app (by clicking on the green run button in eclipse, with my phone connected to my computer by USB), my share button looks like this:
..which is what I want.
When I file -> export my app and install the APK using adb install
(or if I upload the new APK to the play store and install the update), my share button looks like this:
...which is unfortunate.
How do I get the button to look white in the exported app?
Some snippets from my code:
The menu item:
<item
android:id="@+id/menu_item_share"
android:title="@string/action_share"
mysapp:showAsAction="ifRoom"
myapp:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
My res/values/styles.xml:
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="vertical_space">
<item name="android:layout_marginTop">10dp</item>
</style>
res/values-v14/styles.xml:
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
I also have a values-v11/styles.xml with parent="Theme.AppCompat.Light.DarkActionBar"
. I do not have a values-v21 dir.
Edit 1:
I'm trying to think of what changes when exporting the app versus just running it from eclipse.
One possibility is that I have proguard enabled in project.properties
:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
Proguard is only active when exporting, right? Not sure whether that could be an explanation.
Edit 2:
I commented out the proguard.config line in project.properties
and the problem goes away, i.e. the share button is white when exporting the app. I'd like to have proguard enabled, however. How can I both enable proguard and keep the button white when exporting?
Not sure why you're seeing this behavior. But, you can try explicitly defining the tint color for the share drawable. Something like this:
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<!-- Defining actionModeShareDrawable is not really required
<item name="android:textColorSecondary">#b3ffffff</item>
</style>
From what I can tell, the color referenced by attribute textColorSecondary
is used to tint the share drawable. So, being explicit about the color might solve your problem. If you want me to mention how I singled out this attribute (I haven't tested if it even works :) ), let me know.
Edit
Browse to folder (SDK-INSTALLATION) / extras / android / support / v7 / appcompat / res / drawable-xhdpi.
Copy abc_ic_menu_share_mtrl_alpha.png
and paste it to your application's res/drawable-xhdpi
folder. Change its name to say - changed_menu_share.png
.
Your theme should now look like:
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="actionModeShareDrawable">@drawable/changed_menu_share</item>
</style>
This should make the Tintmanager ignore this drawable i.e. it will always be the color you intended - and, in this case, #ffffff. Also notice that we are no longer overriding textColorSecondary
attribute.