Hi Kostya...
the client already rejected my previous approach which involved inspecting
a drawable.
I've finally given them the option of either using ActionBarSherlock and
forcing the use of the overflow menu or developing some custom icons that
will work with both a white or black option menu background. I mocked up
some samples today using their existing custom icon on top of a white
rounded rectangle and they actually look quite good.
Thanks very much for the help and advice though - much appreciated.
Nick
On Friday, August 3, 2012 6:26:10 PM UTC-4, Kostya Vasilyev wrote:
>
>
>
> 2012/8/3 Spiral123
>
>> OK...my second attempt to find the device value of
>> textColorPrimaryDisableOnly:
>>
>> [snip]
>
>
>> My attempt at reflection didn't seem to work either:
>>>
>>>
>> Class myClass = Class.forName("android.R$styleable");
>>>
>>> int mTextColor =
>>>> myClass.getField("Theme_textColorPrimaryInverse").getInt(myClass);
>>>
>>>
>>>>
> You keep trying to get the value of textColorPrimaryDisableOnly from the
> current theme... which mixes up cause and effect (source and target in a
> reference).
>
> But that's irrelevant, because:
>
> I did a bit of checking and found that "style
> name="Widget.TextView.PopupMenu"" is really just for popup menus, which use
> a white background even on 2.3 (where the option menu uses a black
> background... in the stock platform).
>
> The option menu gets its values from a style that's not exposed in the
> SDK, and whose resource Id is thus not guaranteed to be the same, even if
> you used it directly.
>
>
>>
>> Looking for the background 9-patch was no more successful - I couldn't
>> find where menu_background_fill_parent_width.9.png is stored.
>>
>
> It's referenced from the theme as an attribute, called
> "panelFullBackground", and publicly available since API 1.
>
> In XML, you'd write something like:
>
> <ImageView ... android:src="?android:attr/panelFullBackground" ... />
>
> In code, use something like this:
>
> TypedArray a = obtainStyledAttributes(new int[] {
> android.R.attr.panelFullBackground });
> Drawable d = a.getDrawable(0);
> a.recycle();
>
> And to verify, use something like this:
>
>
> ImageView iv = (ImageView) findViewById(R.id.test_menu_background);
> iv.setImageDrawable(d);
>
> The images I'm getting (2.2 and 2.3 emulators) are pure white / pure black
> with slim borders, so it should be really easy to tell them apart.
>
> -- K
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en