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. Do I need to 'make' entire Android platform if I only want the Launcher


My goal:
- Re-build the (built-in)Launcher application and modify/re-skin it
then publish as the new .apk.

My current situation:
1. I installed Ubuntu on my machine and follow the instructions on
this page:
2. I successfully execute "$ repo sync". Now the 2.1GB source is in my

My question:
Allow me to ask before I continue to build the entire platform (which
is said to take up to 6GB including the source).

Q1. If I only need the Launcher then do I need to build the entire

Q2. I also read the page "Using Eclipse for Android platform
development" here :
and it said

"Important: You will still be using "make" to build the files you will
actually run (in the emulator or on a device). You will be using
Eclipse to edit files and verify that they compile, but when you want
to run something you will need to make sure files are saved in Eclipse
and run "make" in a shell. The Eclipse build is just for error

Does this also means I'll need to re-build the entire platform "each
time" I make changes to the source?

Thank you in advance.

P.S. My apology if I sound stupid in your eyes. I actually am an
artist and getting this far to install Ubuntu is already a miracle for
me lol. Thanks again.

2. Does the apk compiled in the old version of android src run on the newer version?

Hi Everyone,

Does the apk compiled in the old version of android src run on the
newer version?

Does google keep the api interface all the time during the update
process of android src?

I hear that a APK should be signed and then can be installed on the
specific device, is it?  Any article that introduce that?


3. ExpandableListView won't redraw, static group data, dynamic child data

4. Audio stops after few seconds in service

5. Can i make a Gallery to Vertical insted of Horizantal ?

6. Getting the Projection Matrix in OpenGL

7. How to configure network in Android-x86 v0.9