Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
ABS menu icons: setEnabled(false)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Oleg Vaskevich  
View profile  
 More options Jun 4 2012, 2:48 am
From: Oleg Vaskevich <theol...@gmail.com>
Date: Sun, 3 Jun 2012 23:48:03 -0700 (PDT)
Local: Mon, Jun 4 2012 2:48 am
Subject: ABS menu icons: setEnabled(false)

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jake Wharton  
View profile  
 More options Jun 4 2012, 3:24 am
From: Jake Wharton <jakewhar...@gmail.com>
Date: Mon, 4 Jun 2012 00:24:28 -0700
Local: Mon, Jun 4 2012 3:24 am
Subject: Re: ABS menu icons: setEnabled(false)

The only possibility is option 1. You cannot accomplish option 2 with the
existing APIs. You can, however, change the icon yourself if the item is
disabled.

---
Jake Wharton
http://about.me/jakewharton


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sérgio Faria  
View profile  
 More options Jun 4 2012, 11:51 am
From: Sérgio Faria <sergio9...@gmail.com>
Date: Mon, 4 Jun 2012 08:51:02 -0700 (PDT)
Local: Mon, Jun 4 2012 11:51 am
Subject: Re: ABS menu icons: setEnabled(false)

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Oleg Vaskevich  
View profile  
 More options Jun 4 2012, 12:08 pm
From: Oleg Vaskevich <theol...@gmail.com>
Date: Mon, 4 Jun 2012 09:08:29 -0700 (PDT)
Local: Mon, Jun 4 2012 12:08 pm
Subject: Re: ABS menu icons: setEnabled(false)

That works great - thank you!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nobu Games  
View profile  
 More options Jun 19 2012, 8:15 pm
From: Nobu Games <dev.nobu.ga...@gmail.com>
Date: Tue, 19 Jun 2012 17:15:46 -0700 (PDT)
Local: Tues, Jun 19 2012 8:15 pm
Subject: Re: ABS menu icons: setEnabled(false)

The Android design guidelines<http://developer.android.com/design/style/iconography.html>for iconography say that disabled action bar icons should have an opacity
of 30% (as opposed to enabled state with opacity 60% for the dark theme or
80% for the light theme). The guidelines also state that action bar icons
should be either a specific shade of gray or white (and not colored).

For coping with that issue I'm using following workaround:

menuItem.getIcon().setAlpha(enabled ? 255 : 64);


255 in case of enabled because my icon graphics already have the required
opacity of 60%.
64 for the disabled icon state because it looked best in my case (using a
light theme).

Actually I was expecting that there is some default behavior that takes
care of that automatically. But I'm getting the impression that Google
simply lets some room for individual theme customizations that have nothing
much in common with the guidelines - like for example colored action bar
items and different disabled state looks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »