简体   繁体   中英

How to get network image height and width using Glide?

I am trying to get height and width of network image. I am using Glide to display image.

Code I've used in Java is:

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);
     }
 });

How can I achieve this in 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)
                    }

                })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM