I have a Xamarin.Android app containing a RecyclerView for which I want to center items. I have created the following LinearSmoothScroller:
public class PlayerSmoothScroller : LinearSmoothScroller
{
public PlayerSmoothScroller(Context context) : base(context) { }
public override int CalculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, int snapPreference)
{return (boxStart + (boxEnd - boxStart) / 2) - (viewStart + (viewEnd - viewStart) / 2);}
}
When I use this, the items get scrolled farther than the edge, and completely into view, but are not quite centered. Here is a sample screenshot:
In this screenshot, the yellow column should be centered, but it is not. I am new to customizing the scrolling, and exactly what the CalculateDtToFit parameters are, but the equation looks correct. Does it have something to do with when it calculates the widths of the columns? Is it related to the fact that not all the columns are the same width? Any help would be appreciated.
