Android学习札记17:ImageView中的setImageBitmap()方法
2012-06-29 10:24
447 查看
在4.0.4 r1.2中查看android.widget.ImageView源代码可以发现,setImageBitmap()方法其实是调用了setImageDrawable()方法进行重绘。
Sets a Bitmap as the content of this ImageView. Parameters: bm The bitmap to set @android.view.RemotableViewMethod public void setImageBitmap(Bitmap bm) { // if this is used frequently, may handle bitmaps explicitly // to reduce the intermediate drawable object setImageDrawable(new BitmapDrawable(mContext.getResources(), bm)); }
Sets a drawable as the content of this ImageView. Parameters: drawable The drawable to set public void setImageDrawable(Drawable drawable) { if (mDrawable != drawable) { mResource = 0; mUri = null; int oldWidth = mDrawableWidth; int oldHeight = mDrawableHeight; updateDrawable(drawable); if (oldWidth != mDrawableWidth || oldHeight != mDrawableHeigh{ requestLayout(); } invalidate(); } }
相关文章推荐
- android 中遇到 imageView getWidth 始终为0 时 ,设置 setImageBitmap 的方法
- android 中遇到 imageView getWidth 始终为0 时 ,设置 setImageBitmap 的方法
- Android中ImageView的setScaleType方法
- Android中ImageView的setScaleType方法属性解析
- gesture-imageview 重复 setImageBitmap 设置图片空白解决方案
- 当一个imageview 使用了 setimagebitmap(bit); 之后 如何从imageview中获取到bit
- NetWorkImageView setImageBitmap无效问题
- Android ImageView setImageBitmap 不显示图片
- Android 从imageview中获得bitmap的方法
- 一种根据ImageView的大小缩放Bitmap的方法
- 对于bitmap和一些设置图片setImageResource()和setImagebitmap()方法减少内存使用的方法
- imageView的ScaleType缩放和setImageResource方法
- Android中ImageView的setScaleType方法
- imageView.setImageUri(uri); imageView.setImageBitmap(bmp)
- setImageView(Bitmap bitmap)报错
- gesture-imageview 重复 setImageBitmap 设置图片空白解决方案
- ImageView setImageBitmap 不显示图片
- 关于真机测试的android选择图片在ImageView上显示,调用setImageBitmap无法显示和闪退、控件消失
- 关于ImageView.setBackgroundResource()方法不显示图片
- 解决Android ImageView用setImageDrawable方法图片缩小的问题