簡體   English   中英

如何使用 Glide 獲取網絡圖像的高度和寬度?

[英]How to get network image height and width using Glide?

我正在嘗試獲取網絡圖像的高度和寬度。 我正在使用 Glide 來顯示圖像。

我在 Java 中使用的代碼是:

Glide.with(getContext().getApplicationContext())
 .asBitmap()
 .load(path)
 .into(new SimpleTarget<Bitmap>() {
     @Override
     public void onResourceReady(Bitmap bitmap,
                                 Transition<? super Bitmap> transition) {
         int w = bitmap.getWidth();
         int h = bitmap.getHeight()
         mImageView.setImageBitmap(bitmap);
     }
 });

如何在 Kotlin 中實現這一點?

Glide.with(context.applicationContext)
                .asBitmap()
                .load(path)
                .into(object : SimpleTarget<Bitmap?>() {
                    override fun onResourceReady(bitmap: Bitmap, transition: Transition<in Bitmap?>?) {
                        val w = bitmap.width
                        val h = bitmap.height
                        mImageView.setImageBitmap(bitmap)
                    }

                })

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM