I am using a Xamarin.Forms AbsoluteLayout when I want new controls to be added to it when the user scrolls. Why? Because adding everything when the page 1st opens would take a lot of time since there are lots of items.
I am using an AbsoluteLayout
, whose Children
are custom layouts that inherit from Layout<View>
. Before I add the controls to the Children
I update their Bounds
property so that they know where to place themselves.
It looks like every time I call AbsoluteLayout.Children.Add()
, all the existing children are measured and places, that is, it looks like a full layout cycle is triggered.
Anyone knows how to bypass this? (I have tried CollectionView
, however it has a known issue of jitter on Android, so i am trying to find an alternative).
Any education/info is much appreciated. Thanks!
Yes,you can.Basically,there are two ways.
1.You can create an async method to run your "content/view creation" on a background thread and then when you need to add that child view to the UI, add it on the main/UI thread (BeginInvokeOnMainThread).You can refer to this link.
2.You can add views to its child in OnAppearing() method which is prior to the Page becoming visible that renders the page faster.
protected override void OnAppearing()
{
base.OnAppearing();
//add views to its child here
}