通过图片url显示图片在imageview上
2018-03-13 16:03
555 查看
public Bitmap getBitmap(String url) { Bitmap bm = null; try { URL iconUrl = new URL(url); URLConnection conn = iconUrl.openConnection(); HttpURLConnection http = (HttpURLConnection) conn; int length = http.getContentLength(); conn.connect(); // 获得图像的字符流 InputStream is = conn.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is, length); bm = BitmapFactory.decodeStream(bis); bis.close(); is.close();// 关闭流 } catch (Exception e) { e.printStackTrace(); } return bm; }
//或者是通过glide框架 Glide.with(this).load(url).bitmapTransform( new GlideRoundTransform(this, 2)).placeholder(R.drawable.img_default) .error(R.drawable.img_default ).into(mIvView);
相关文章推荐
- 通过URLHttpConnection方式来取得图片,并且显示在ImageView上
- 通过URLHttpConnection方式来取得图片,并且显示在ImageView上
- Android 通过url获取网络图片并显示在ImageView中
- 获取服务器Url图片资源,并显示在ImageView中 Android
- 获取sd卡中的图片URL并显示,同时使用ImageView把选择的图片展现出来
- 图片不能显示: [cell.imageView setImageWithURL:imageUrl placeholderImage:nil options:SDWebImageLowPriority
- 通过图片的url获取Bitmap对象,给Imageview使用
- 根据url下载一张大小为1M左右的图片,然后用个ImageView显示出来。不爆内存的哦!!!
- 在android中用NetworkImageView读取网络图片并通过ListView显示出来
- android 通过uri截取指定大小的图片显示在imageview上
- IOS开发-UI学习-根据URL显示图片,下载图片的练习(button,textfield,image view,url,data)
- Android中利用OnTouchListener在ImageView中框选显示图片
- 通过s:graphicImageDynamic组件显示保存到数据库中的图片
- imageview无法显示图片:java.lang.RuntimeException: Canvas: trying to draw too large(281520000bytes) bitmap
- 聊天界面自定义cell中的image view加载网络图片不显示
- Android用ImageView显示本地和网上的图片(转)
- ImageViewd的图片显示问题
- ImageView显示不出来图片
- Android ImageView&ImageButton 显示图片的一些总结
- Android ImageView 不显示JPEG图片 及 Android Studio中如何引用图片资源