On Monday, June 4, 2012 11:51:02 AM UTC-4, Sérgio Faria wrote:
> I use a color filter, I've no idea how close the effect is to the "native
> filter", but looks great.
> /**
> * Mutates and applies a filter that converts the given drawable to a
> Gray image. This method
> * may be used to simulate the color of disable icons in Honeycomb's
> ActionBar.
> *
> * @return a mutated version of the given drawable with a color filter
> applied.
> */
> public static Drawable convertDrawableToGrayScale(Drawable drawable) {
> if (drawable == null) {
> return null;
> }
> Drawable res = drawable.mutate();
> res.setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN);
> return res;
> }
> Segunda-feira, 4 de Junho de 2012 7:48:03 UTC+1, Oleg Vaskevich escreveu:
>> In my app, I need to disable menu items depending on the state of a
>> database. I do this with SherlockActivity.supportInvalidateOptionsMenu() and
>> calling setEnabled(false) on the menu items I want to disable. While
>> this does disable the text, the icons remain the same - they are not
>> "grayed out" or anything.
>> Is this intended behavior? If not, I'd still like to give the icons a
>> disabled look. Looks like there are two options:
>> 1. Use a StateListDrawable to set disabled versions of icon files
>> 2. Look to see how Android makes icons disabled on previous versions.
>> This could be possibly be done using setAlpha() or setColorFilter(...)
>> Any suggestions (esp. regarding where to look for #2 - MenuItem.java?
>> That's just an interface) would be appreciated.