AndroidImageSlider icon indicating copy to clipboard operation
AndroidImageSlider copied to clipboard

How to use wrap_content on SliderLayout height

Open anupamchugh opened this issue 9 years ago • 5 comments

I want the slider layout height to be wrap_content and equal to the images instead of hardcoding as 200dp.

anupamchugh avatar Jun 15 '16 06:06 anupamchugh

the same problem

protectedMan avatar Mar 06 '17 03:03 protectedMan

Same here

loirotv avatar Dec 22 '17 15:12 loirotv

the same problem when set wrap_content for height attribute ImageSlider dose not show

siavash-sajjad avatar Mar 03 '18 04:03 siavash-sajjad

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) {

            }
        });`

where did you add this code?

behiunforgiven avatar Dec 10 '18 18:12 behiunforgiven