ImageView显示图像
2010-10-07 00:03
393 查看
ImageView显示图像有多个方法
setImageResource(int resId);
setImageURI(Uri uri);
setImageDrawable(Drawable drawable);
setImageBitmap(Bitmap bm);
对于资源图像,可以直接应用调用资源来显示,但是有时候我们需要对显示的图像先做某种操作,因此需要把资源转换为BitmapDrawable或者Bitmap
1、从资源中获取BitmapDrawble
2、从资源中获取Bitmap图像
setImageResource(int resId);
setImageURI(Uri uri);
setImageDrawable(Drawable drawable);
setImageBitmap(Bitmap bm);
对于资源图像,可以直接应用调用资源来显示,但是有时候我们需要对显示的图像先做某种操作,因此需要把资源转换为BitmapDrawable或者Bitmap
1、从资源中获取BitmapDrawble
private BitmapDrawable getDrawableFromId(int id){ Resources res = getResources(); return (BitmapDrawable)res.getDrawable(id); }
2、从资源中获取Bitmap图像
private Bitmap getBitmapFromId(int id){ Resources res = getResources(); BitmapDrawable bitDraw = new BitmapDrawable(res.openRawResource(R.drawable.lander_firing)); Bitmap bm = bitDraw.getBitmap(); return bm; //mImageView.setImageBitmap(bm); }
相关文章推荐
- 如何在ImageView组件中显示图像的一部分
- UI控件之显示图像控件ImageView(下)
- ImageView显示图像控件
- 正确的添加图片方法 - 解决UIImageView.image = UIImage(named: String)不显示图像的问题
- ImageView图像控件之裁剪和显示
- [原创]可动态显示圆形图像或圆形文字的AvatarImageView
- [一个星期自学安卓]使用ImageView显示gif图像
- android-----使用ImageSpan对象在TextView组件中显示图像
- ImageView显示图像有多个方法
- 在ImageView中显示图像的一部分
- UI控件之显示图像控件ImageView(上)
- 动画--问题追踪:ImageView执行缩放动画ScaleAnimation之后,图像显示不全的问题。
- ImageView显示图像控件(基本用法)
- 可动态显示圆形图像或圆形文字的AvatarImageView
- Android开发使用XML文件定义ImageView的在selected为true和false状态下显示不同的图像
- [一个星期自学安卓]ImageView的适屏显示及图像的裁剪
- [一个星期自学安卓]使用ImageView显示网络图像
- [一个星期自学安卓]使用ImageView显示图像的缩放与旋转
- 自定义圆形图片显示控件CircleImageView
- Swift中tableViewCelll和ImageView中图片背景显示的问题