Search code examples
androidandroid-recyclerviewandroid-imageviewlayoutparams

Setting a recyclerView's imageView cells to a specific width and length


I have created a gridView layout with a RecyclerView and have also created the necessary adapter class to populate its cells with imageViews.However, i can't figure out how to make the imageViews larger or set a custom length and width for them.In a previous project, i was using LayoutParams directly on the imageViews like this:

imageView.setLayoutParams(new GridView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

But that doesn't seem to work here.Any ideas?


Solution

  • If anyone is interested, i solved it by implementing the solution to this question : match_parent width does not work in RecyclerView.