diff options
author | Dan Sandler <dsandler@android.com> | 2015-05-13 00:12:47 -0400 |
---|---|---|
committer | Dan Sandler <dsandler@android.com> | 2015-05-13 23:50:39 -0400 |
commit | a22a380fbbe224783d8b82440ca8692b0ff5b0a2 (patch) | |
tree | d965ccd538b3c915f517f933122f54683f8ed96b /core/java/android/widget/ImageView.java | |
parent | ae597c33dc3697cf5c314d88cb597cb41c362eb3 (diff) | |
download | frameworks_base-a22a380fbbe224783d8b82440ca8692b0ff5b0a2.zip frameworks_base-a22a380fbbe224783d8b82440ca8692b0ff5b0a2.tar.gz frameworks_base-a22a380fbbe224783d8b82440ca8692b0ff5b0a2.tar.bz2 |
Add Icon support to ImageView.
ImageView.setImageIcon() is remotable, so you can also call
RemoteViews.setImageViewIcon().
Bug: 18568715
Change-Id: I456cfa65102e1983d3392d822584d154a6cd761a
Diffstat (limited to 'core/java/android/widget/ImageView.java')
-rw-r--r-- | core/java/android/widget/ImageView.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 05059bc..94cda88 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -36,8 +36,10 @@ import android.graphics.RectF; import android.graphics.Xfermode; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.Icon; import android.net.Uri; import android.os.Build; +import android.os.Handler; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; @@ -462,6 +464,21 @@ public class ImageView extends View { } /** + * Sets the content of this ImageView to the specified Icon. + * + * <p class="note">Depending on the Icon type, this may do Bitmap reading and decoding + * on the UI thread, which can cause UI jank. If that's a concern, consider using + * {@link Icon#loadDrawableAsync(Context, Handler, Icon.OnDrawableLoadedListener)} + * and then {@link #setImageDrawable(android.graphics.drawable.Drawable)} instead.</p> + * + * @param icon an Icon holding the desired image + */ + @android.view.RemotableViewMethod + public void setImageIcon(Icon icon) { + setImageDrawable(icon.loadDrawable(mContext)); + } + + /** * Applies a tint to the image drawable. Does not modify the current tint * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. * <p> |