In Recyclerview in Android we may want to give alternate colors to the rows. I will show you an easy way to do that, just put the below code in onBindViewHolder of the adapter class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(position %2 == 1) | |
{ | |
holder.itemView.setBackgroundColor(Color.parseColor("#E1F7F7F7")); | |
// holder.imageView.setBackgroundColor(Color.parseColor("#FFFFFF")); | |
} | |
else | |
{ | |
holder.itemView.setBackgroundColor(Color.parseColor("#FFFFFF")); | |
// holder.imageView.setBackgroundColor(Color.parseColor("#FFFAF8FD")); | |
} |
0 comments:
Post a Comment