2
votes

I have an app which loads images from api into my imageView which is in my RecyclerView.

Here is my ImageView :

        <ImageView
        android:id="@+id/Group_ImageView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="100dp"
        android:layout_alignParentTop="true"
        android:background="@color/_Opacity"
        android:scaleType="centerInside"
        android:src="@mipmap/ic_launcher" />

and here is the image loading part in my adapter with glide :

        Glide.with(mContext).load(goodGroups.getImageUrl()).asBitmap().dontTransform().listener(new RequestListener<String, Bitmap>() {
        @Override
        public boolean onException(Exception e, String s, Target<Bitmap> target, boolean b) {
            return false;
        }

        @Override
        public boolean onResourceReady(Bitmap bitmap, String s, Target<Bitmap> target, boolean b, boolean b1) {
            bitmap.setDensity(mContext.getResources().getDisplayMetrics().densityDpi);
            return false;
        }
    }).placeholder(R.mipmap.ic_launcher).error(R.drawable.ic_menu_gallery).into(holder.imageView);

here is the screen shot of my problem below : issue screen shot

my problem is with the part shown by red line in the picture. the blue line shows my imageview. the red part isn't supposed to be shown. I've tried changing the ScaleType to "FitXY" or "CenterCrop" but it messes up with the picture size.I want my picture shown without any cropping, with it's original size and without these padding like spaces in ImageView.

What should I do?!

3
@color/opacity code and image url pls give to me - Bhuvaneshwaran Vellingiri
@BhuvaneshwaranVellingiri I've checked the image, and there is no problem with it, the picture has no padding or empty space with it. The gray part is my ImageView's background which the @color/opacity. I've changed it like this so it can be shown easily to you. - S.Aslpour

3 Answers

2
votes

set android:adjustViewBounds="true" for your ImageView in the code

2
votes

Try this set Image url.

 Glide.with(getBaseContext())
.load("Your image url parse this place")
               .diskCacheStrategy(DiskCacheStrategy.ALL)
                .thumbnail(0.1f)
                .into(img_glide);
0
votes

try following you have to user centerCrop or fitCenter methods.

Glide.with(context).load(url).centerCrop().placeholder(R.drawable.default_image).into(img);

or

Glide.with(context).load(url).fitCenter().placeholder(R.drawable.default_image).into(img);

or

Glide.with(getActivity().getApplicationContext())
                .load(url).fitCenter()
                .override(500, 758)
                .into(mMovieBackgroundImageView);