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.
Calling "setInt" for "setAlpha" works starting with 2.2 - where
ImageView.setAlpha is marked with @RemotableViewMethod.
I know this is doable because other application widgets have
sliders to set the transparency at runtime. But how?
Another option would be to change the image in your app's code, by using
Drawble.setAlpha.
It's what ImageView.setAlpha does:
mDrawable = mDrawable.mutate();
mDrawable.setAlpha(mAlpha * mViewAlphaScale >> 8);
Then you have two options: sending the image in RemoteViews over RPC as
a bitmap with setImageViewBitmap() (probably won't work for nine
patches, and/or might need explicit bounds values set first) or saving
it to a temporary file and using setImageViewUri.
Given that its usually Kostya that answers my widget questions (thanks,
Kostya!) it looks like there may be a paucity of widget authors
frequenting this group. But I figure there is no harm in trying again.
Ok, that's pretty much all I have to say about this. I'll keep quiet
now, hoping for someone more knowledgeable to answer :)
-- Kostya
--
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