I need to color list item diagonally of grid layout manager of span count 2
for example:
Please provide any logic for this for coloring item of recyclerview
corresponding image
In this picture item next to hindi is has to color as item english is colored
As @Pawel mentioned in the comment, you can add the following logic in your onBindViewHolder
function:
val mod = adapterPosition % 4
val backgroundColor = if(mod == 0 || mod == 3) color1 else color2
// Set this color to your view
Here color1
will be set for elements at index 0, 3, 4, 7, 8, ... and color2
will be set for the remaining positions.