12.04.2011 20:50, Jake Colman пишет:
   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?

That's just code from Android sources, specifically ImageView.

Drawables use integer alpha values, the range is [0 ..255], whereas View.setAlpha takes a float [0.0f .. 1.0f], so it's just scaling the value.


    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.

This makes two assumptions: that NinePatch.setAlpha actually modifies the image data, and that it's reasonably simple to save a nine patch as a .PNG.

I don't know if those assumptions are correct, but then I don't have all the answers :)

A dumb question: setting
the image view has the effect of resetting the layout's background
attribute?

No, an image view is independent of other views or layouts. It also draws its image as the content, not as the background.

And here is something really interesting in RemoteViews:

public void setDrawableParameters(int viewId, boolean targetBackground, int alpha,
            int colorFilter, PorterDuff.Mode mode, int level)

This method can change the alpha, or apply a color filter to an ImageView drawable, and what's even more amazing, it can also make those changes to the background of any view, e.g. a Layout. And it's there as early as 1.6.

Unfortunately, it's hidden from the SDK. But perhaps those "other" widgets call it using Java reflection?

--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
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

Reply via email to