LinearSmoothScroller.TargetPosition = position Įach item in my RecyclerView is a GridLayout which contains an EditText & Button. Public override void SmoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position)ĬustomSmoothScroller linearSmoothScroller = new CustomSmoothScroller(mainActivity) This.mainActivity = (MainActivity)context Public MyLinearLayoutManager(Context context) : base(context) Public class MyLinearLayoutManager : LinearLayoutManager Return base.CalculateDtToFit(viewStart, viewEnd, boxStart, bo圎nd, -1) Public override int CalculateDtToFit(int viewStart, int viewEnd, int boxStart, int bo圎nd, int snapPreference) Public CustomSmoothScroller(Context context) : base(context)
public class CustomSmoothScroller : LinearSmoothScroller Here is the sample code, you could refer to it. Could you please share more details about the featur you want to achieve? If you want to scroll to a position and place each corresponding item at the top or end, change the value of the snapPreference property. This override is always called & returns the desired value, so why does it not always use the returned value?
However, I have confirmed that the code above is being called & returning the desired values (for both completely & partially visible items), yet it only scrolls the returned value for completely visible items (partially visible items do scroll, but not by the amount returned here). What it looks like it is doing for the partially visible items is using base.CalculateDtToFit with the original values & SnapToAny rather than what I have in the code above. However, for items that are only partially visible (not completely offscreen, just not 100% within view), it does not. When I call SmoothScrollToPosition(x) to scroll to a RecyclerView item that is completely visible, everything works exactly as expected. If (((MainActivity)).rvPlayerNamesInput.GetAdapter().ItemCount = 1)
I have a SmoothScroller that inherits from LinearSmoothScroller, and I override CalculateDtToFit as follows: public override int CalculateDtToFit(int viewStart, int viewEnd, int boxStart, int bo圎nd, int snapPreference)