简体   繁体   中英

Get Width and Height from Picasso Image Downloaded

I'm using a library (SliderLayout) that utilizes Picasso for downloading it's images but I'm not sure how to extract the width and height from those downloaded images. Any ideas?

    imageURLs = getActivity().getResources().getStringArray(R.array.image_urls);

    imageSlide = (SliderLayout) view.findViewById(R.id.gallery_slider);

    ArrayList<DefaultSliderView> slides = new ArrayList<DefaultSliderView>();

    for(int i = 0; i < imageURLs.length; i++){
        currentSlidePosition = i;

        DefaultSliderView slide = new DefaultSliderView(getActivity());
        slide.image(imageURLs[i]);

        //need width and height of image downloaded here

        slides.add(slide);
        imageSlide.addSlider(slide);

A common method is using Picasso load like that:

 Picasso.with(this).load("http://").into(new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            int width = bitmap.getWidth();
            int height = bitmap.getHeight();
            imgView.setImageBitmap(bitmap);
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {

        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {

        }
    });

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