码迷,mamicode.com
首页 > Web开发 > 详细

ImageView 设置图片来自:http://blog.csdn.net/lincyang/article/details/6562163

时间:2017-10-05 13:06:12      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:bsp   pos   nbsp   csdn   ble   color   cto   osi   type   

android doc中是这样描述的:



public void setImageResource (int resId)

这是其中的一个方法,参数resld是这样:

ImageView.setImageResource(R.drawable.icon);

 

看下面这段话



Sets a drawable as the content of this ImageView.

This does Bitmap reading and decoding on the UI thread, which can cause a latency hiccup. If that‘s a concern, consider usingsetImageDrawable(Drawable) or setImageBitmap(Bitmap) and BitmapFactory instead.

 

此函数使用UI线程,可以用下面3种替代:

ImageView iv; 

String fileName = "/data/data/com.test/aa.png; 
Bitmap bm = BitmapFactory.decodeFile(fileName); 
iv.setImageBitmap(bm); 


ImageView iv = new ImageView(context); 
iv.setImageResource(iv[position]); 
iv.setScaleType(ImageView.ScaleType.FIT_XY); 
iv.setLayoutParams(new Gallery.LayoutParams(136,88)); 


mImageView = (ImageView)this.findViewById(R.id.myImageView1); 
mImageView.setImageDrawable(getResources().getDrawable(R.drawable.right)

 

ImageView 设置图片来自:http://blog.csdn.net/lincyang/article/details/6562163

标签:bsp   pos   nbsp   csdn   ble   color   cto   osi   type   

原文地址:http://www.cnblogs.com/gisoracle/p/7628992.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!