I currently am developping an Android app in which I use a recyclerView to show the user a list of available services of the app. Right now the list's UI is a simple two-columns, scrollable recyclerView who look like the items are snapped just like in a gridview.
I'd like to offset the second column of the recyclerView so it would look kinda like how a keyboard's keys rows do, not aligning items perfectly.
I've seen another question that asks for the same thing as me (though horizontally and not vertically) but the answers didn't help and I don't want to necromance the thread back to life ^^ RecyclerView - horizontal, two-row grid, second row offset
Does anyone know of a way to do this ? maybe a library exists somewhere but I looked everywhere I could find answers without success...
Edit : Thanks to Bled K. for the solution :D I added this function and called it in the OnBindViewHolder :
public void setViewOffset(int position){
if(position==1){
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) this.f.getLayoutParams();
params.topMargin = cardView.getHeight()/3;
this.f.setLayoutParams(params);
}else{
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) this.f.getLayoutParams();
params.topMargin = 0;
this.f.setLayoutParams(params);
}
}
in my case this.f is the constraintLayout that contains my cardview and all.