Another question: At some point this explanation breaks down, because in my experience, this happens only the FIRST time I attempt to change a button's image's state... on subsequent attempts, all works properly. So apparently something "triggers" correct behavior at some point, suggesting there is a workaround, but I searched in vain for days for one. Is there a way to defeat this behavior beyond physically including redundant copies of resources?
On Jan 28, 11:11 am, Sundog <sunns...@gmail.com> wrote: > Last time you mentioned this, in response to my question about it, you > said that it was a known issue and that you were personally working on > fixing it. > > So is this an "issue" that will be fixed at some point, or are we now > regarding this bug as something that won't be fixed? > > On Jan 28, 10:09 am, Romain Guy <romain...@google.com> wrote: > > > > > Hi, > > > 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. > > > On Wed, Jan 28, 2009 at 3:36 AM, pmilosev <pmilo...@gmail.com> wrote: > > > > Hi > > > > I have several state-full custom buttons, each composed of three parts > > > (image views): back, middle, front. > > > On state change color filter (tint) is applied / removed to the middle > > > and front part. > > > On focus change color filter is applied / removed to the back part of > > > the button (the image on the bottom). > > > > Randomly, after several filters are applied (due to state change) the > > > filters will start to be rendered incorrectly. > > > E.g. On next focus change all the buttons would be marked as they have > > > changed state. > > > The color filter will not be removed when the button lose > > > focus. > > > Sometimes only portions of the button is tinted (although it > > > should not be affected). > > > Sometimes the transparent parts of the image are affected, > > > although I use SRC_ATOP mode. > > > > To apply color filter I use: > > > myImageView.setColorFilter(myColor, Mode.SRC_ATOP); > > > > To remove color filter I have tried: > > > myImageView.setcolorFilter(null); OR myImageView.setColorFilter > > > (Color.TRANSPARENT, Mode.SRC_ATOP); > > > > Please note that everything works fine until several color filters are > > > applied, after that tinting errors appear randomly; > > > > Am I missing something (e.g calling some method to force view to > > > redraw) since I could not find anyone having > > > similar problems ? > > > > regards > > > -- > > Romain Guy > > Android framework engineer > > romain...@android.com > > > 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- Hide quoted text > > - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---