zoukankan      html  css  js  c++  java
  • Glide 加载图片 到动态ImageView

    Glide.with(mContext)
    .asBitmap()
    .load(imageUrl)
    .apply(options)
    //.into(mImageView);
    .into(mTarget);

    下面在获取到下载图片尺寸信息后,在给imageview 设置图片资源,
    private SimpleTarget mTarget = new SimpleTarget<Bitmap>() {
    @Override
    public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
    int imageWidth = resource.getWidth();
    int imageHeight = resource.getHeight();
    int layoutWidth = mImageLayoutWidth;
    int layoutHeight = mRecyclerView.getLayoutParams().height;
    float imageRatio = (float) imageWidth / imageHeight;
    float layoutRatio = (float) layoutWidth / layoutHeight;
    int imageViewHeight = 0;
    int imageViewWidth = 0;
    if (imageRatio > layoutRatio) {
    imageViewWidth = layoutWidth;
    imageViewHeight = (int) ((float) layoutWidth / imageRatio);
    } else {
    imageViewHeight = mRecyclerView.getLayoutParams().height;
    imageViewWidth = (int) (imageRatio * imageViewHeight);
    }
    LogUtil.i(TAG + " mTarget.onResourceReady() imageWidth:" + imageWidth + " imageHeight:"
    + imageHeight + " imageViewWidth:" + imageViewWidth + " imageViewHeight:" + imageViewHeight
    + " layoutWidth:" + layoutWidth + " layoutHeight:" + layoutHeight);
    ViewGroup.LayoutParams para = mImageView.getLayoutParams();
    para.height = imageViewHeight;
    para.width = imageViewWidth;

    mImageView.setImageBitmap(resource);
    }
    };
  • 相关阅读:
    apache的用户认证
    Apache的配置文件
    AH00052: child pid 25043 exit signal Segmentation fault (11)
    Apache的工作模式
    apache的目录别名
    RAID的几种级别
    网络服务--NFS服务
    MySQL 5.7元数据库
    [ERROR] COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8'
    .Net MVC断点进不去
  • 原文地址:https://www.cnblogs.com/adamli/p/14030067.html
Copyright © 2011-2022 走看看