problems when setting / removing color filter to image views

by Romain Guy » Thu, 29 Jan 2009 01:09:59 GMT

Sponsored Links

The problem comes from a rather unknown feature of resources and
drawables. The state of several drawables that come from the same
resource is shared across all the drawables. Take this example:

Drawable d1 = getResources().getDrawable(R.drawable.my_image);
Drawable d2 = getResources().getDrawable(R.drawable.my_image);

d2.setAlpha(0); // Sets the alpha value of d2 *and* d1 to 0

The two drawables are different objects but they both use the same
"constant state" (it's the actual name of the implementation) which
contains, among other things, the alpha value, the bitmap... and the
color filter.

This behavior comes from the necessity to optimize the memory usage
and the loading times of applications. By doing so we have only one
constant state used by all buttons across all applications.

Romain Guy
Android framework engineer

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them


Other Threads

1. "Failed to reopen debug port for Selected Client to: 8700" error

Hi Lads:
    I'm a beginner of Android, I just installed environment today.
After installation, I got
 [2009-03-15 22:06:10 - ddms]Failed to reopen debug port for Selected
Client to: 8700
[2009-03-15 22:06:10 - ddms]Address family not supported by protocol
family: bind Address family not supported by protocol
family: bind
error on my eclipse console(3.3.2, europa). Any one have any idea why
does this happen and how to fix it? Many thanks.


2. About Google Map Installation on Target

Hi All,

I have couple of doubts regarding Google Map Usage as below:

1. I am able to run Google Map Application on Emulator with proper API
 Google Map is not open source and not available on Target Board,
so I am not able to execute this application.
Does same API Key hold good for Target Board also or Is there
something else need to be done
for it ?

2. What will Google provide as Google Map Installation Package
( Legal one ) for Google Map for Target ? i.e. How Google Map
Installer will
be different from Emulator's Google Map ? What are the other security
means used to Secure Google Map Installer from running on Target Board
except API Key and signed .apk file ?


3. How to overlay animation upon a View

4. class does not exist?

5. Making things louder

6. List of private / hidden / system APIs?

7. Network activity for each Process (based on PID)