Image size in the center changed with gridlayoutmanager 3 spancount

72 Views Asked by At

I have recyclerview with gridlayoutmanager with spancount of 3. Imageview size in center is different from others. I have tried all scaletypes but nothing helps.

private fun initRecycler(){
            val gridLayoutManager = GridLayoutManager(context,3)
            binding.rvWallpapers.layoutManager = gridLayoutManager
            mainAdapter = MainAdapter(context, this)
            binding.rvWallpapers.addOnScrolledToEnd {
                binding.skvLoadingEnd.isVisible = true
                initCategory()
            }
            binding.rvWallpapers.adapter = mainAdapter
        }
    

Glide.with(context).load(sizesModel.url).centerCrop().listener(object :RequestListener<Drawable?>{
            override fun onLoadFailed(
                e: GlideException?,
                model: Any?,
                target: Target<Drawable?>?,
                isFirstResource: Boolean
            ): Boolean {
                return false
            }

        override fun onResourceReady(
            resource: Drawable?,
            model: Any?,
            target: Target<Drawable?>?,
            dataSource: DataSource?,
            isFirstResource: Boolean
        ): Boolean {
            Log.d("sizes", "width: "+binding.ivWallpapers.width.toString()+"height: "+binding.ivWallpapers.height.toString())
            binding.skvLoading.isVisible = false
            return false
        }
    }).into(binding.ivWallpapers)

Here is log:

D/sizes: width: 465height: 930
D/sizes: width: 470height: 940
D/sizes: width: 465height: 930
D/sizes: width: 465height: 930
D/sizes: width: 470height: 940
D/sizes: width: 465height: 930
D/sizes: width: 465height: 930
D/sizes: width: 470height: 940
D/sizes: width: 465height: 930

imageview in center has 470 width and 940 height, however imageviews from left side and right side have 465 width and 930 height

0

There are 0 best solutions below