Android学习札记17:ImageView中的setImageBitmap()方法
16lz
2021-12-04
在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.RemotableViewMethodpublic void setImageBitmap(Bitmap bm) {// if this is used frequently, may handle bitmaps explicitly// to reduce the intermediate drawable objectsetImageDrawable(new BitmapDrawable(mContext.getResources(), bm));}
Sets a drawable as the content of this ImageView.Parameters:drawable The drawable to setpublic 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调用系统程序
- android输入法全屏问题
- android 去掉listview之间的黑线
- Android(安卓)Webview播放HTML5 video的一个思路
- Java中的instanceof关键字在Android中的用法
- Android(安卓)java.lang.IllegalArgumentException: pointerInde
- Android:解决列表滚动时背景色变黑的方法
- 2014.04.21 ——— android 魅族SmartBar判断
- Android(安卓)studio 中调用ndk-build 进行编译native 层直接编