AndroidImageSlider icon indicating copy to clipboard operation
AndroidImageSlider copied to clipboard

How can I override methods to set "wrap_content" for the sliderview instead of giving a specify width/height

Open capsulejj opened this issue 10 years ago • 7 comments

How can I override methods to set "wrap_content" for the sliderview instead of giving a specify width/height?

and thanks for such a useful library.

capsulejj avatar Jan 03 '15 09:01 capsulejj

Hurray!

I finally solve it by some tricky ways. but i hope you should fix this as this can be important for some developers.

Anyway, thanks for your library.

capsulejj avatar Jan 03 '15 11:01 capsulejj

@capsulejj can you share the way. Because wrap_content and match_parent are not working in SliderLayout

vikasvmane avatar Jun 04 '15 08:06 vikasvmane

I need to find it out. But I really think my way is really terrible and unexplainable. I will give it to you if i found it

capsulejj avatar Jun 04 '15 08:06 capsulejj

@capsulejj when you find it out i would like to know your solution as well,thanks!

Dadoufi avatar Jun 23 '15 11:06 Dadoufi

i fix it with

` Picasso.get().load(imageUrl)).into(new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {

                int width = bitmap.getWidth();
                int height = bitmap.getHeight();

                int tempWidth = (int) (width / Resources.getSystem().getDisplayMetrics()
                    .density);

                int sliderHeight = (int) (height / Resources.getSystem().getDisplayMetrics()
                    .density) * slider.getWidth() / tempWidth;
                ;

                slider.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams
                    .MATCH_PARENT, sliderHeight));
            }

            @Override
            public void onBitmapFailed(Exception e, Drawable errorDrawable) {

            }

            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {

            }
        });`

MrzAhmadi avatar Sep 10 '18 12:09 MrzAhmadi

i fix it with

` Picasso.get().load(imageUrl)).into(new Target() { @override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {

                int width = bitmap.getWidth();
                int height = bitmap.getHeight();

                int tempWidth = (int) (width / Resources.getSystem().getDisplayMetrics()
                    .density);

                int sliderHeight = (int) (height / Resources.getSystem().getDisplayMetrics()
                    .density) * slider.getWidth() / tempWidth;
                ;

                slider.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams
                    .MATCH_PARENT, sliderHeight));
            }

            @Override
            public void onBitmapFailed(Exception e, Drawable errorDrawable) {

            }

            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {

            }
        });`

how to implement this if I'm not using picasso ?

felangga avatar Sep 13 '18 06:09 felangga

with

get the image size and resize height image to the percent of width image in the display

MrzAhmadi avatar Sep 15 '18 10:09 MrzAhmadi