>>>>> "KV" == Kostya Vasilyev <[email protected]> writes:
KV> 12.04.2011 17:19, Jake Colman пишет: >> I have yet to figure this out so I though I'd try posting again. >> >> Given a widget with a background image specified in its layout, >> how can one set the background's transparency at runtime? >> >> I have tried Kostya's suggestion of calling the >> RemoteView.setInt() method and passing in setAlpha as the >> methodName but I get a reflection error. KV> Calling "setInt" for "setAlpha" works starting with 2.2 - where KV> ImageView.setAlpha is marked with @RemotableViewMethod. This is good to know but I'd like to be able continue targeting 1.6 devices as well. >> I know this is doable because other application widgets have >> sliders to set the transparency at runtime. But how? KV> Another option would be to change the image in your app's code, KV> by using Drawble.setAlpha. KV> It's what ImageView.setAlpha does: KV> mDrawable = mDrawable.mutate(); KV> mDrawable.setAlpha(mAlpha * mViewAlphaScale >> 8); So get the Drawable via its resource ID and mutate it? How did you come up with the arguments for setAlpha? Can you explain them, please? KV> Then you have two options: sending the image in RemoteViews over KV> RPC as a bitmap with setImageViewBitmap() (probably won't work KV> for nine patches, and/or might need explicit bounds values set KV> first) or saving it to a temporary file and using KV> setImageViewUri. Its a 9-patch so I'll go with setImageViewUri. A dumb question: setting the image view has the effect of resetting the layout's background attribute? -- Jake Colman -- Android Tinkerer -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

