这个可以bai控制popupwindow的隐藏du,可以实现点击zhipopupwindow以外的区域时隐藏popupwindow,还有dao一个功能就是响应back键。实版现按back键可以隐权藏popupwindow的功能。
ImageView中的属性方法 setBackgroundDrawable(drawable) 代表以这个drawable为背景来填充ImageView的宽高 及ImageView多高多宽,drawable也相应放大至多高多宽
setImageDrawable(drawable) 代表以这个drawable的实际大小放到ImageView中,并不会放大drawable的实际大小
获取资源文件 r.drawable中的图片转换为drawable、bitmap
1、
Resources resources = mContext.getResources();
Drawable drawable = resources.getDrawable(R.drawable.a);
imageview.setBackground(drawable);
2、
Resources r = this.getContext().getResources();
Inputstream is = r.openRawResource(R.drawable.my_background_image);
BitmapDrawable bmpDraw = new BitmapDrawable(is);
Bitmap bmp = bmpDraw.getBitmap();
3、
Bitmap bmp=BitmapFactory.decodeResource(r, R.drawable.icon);
Bitmap newb = Bitmap.createBitmap( 300, 300, Config.ARGB_8888 );
4、
InputStream is = getResources().openRawResource(R.drawable.icon);
Bitmap mBitmap = BitmapFactory.decodeStream(is);