Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Super speedup by overriding layout methods (XF 1.3)

$
0
0

Hi all,

i was struggling to get any performance out of my Android app, tried everything that was mentioned in these forums. I did find a solution that might help others to (if not already known and my googling efforts were useless).

For views (like a grid or a contentview) that has children that never influence the container (e.g. a listview that always is on the left part of the screen and never resizes), derive a class and override

        protected override bool ShouldInvalidateOnChildAdded(View child)
        {
            return false;
        }

        protected override void OnChildMeasureInvalidated()
        {

            //base.OnChildMeasureInvalidated();
        }

        protected override bool ShouldInvalidateOnChildRemoved(View child)
        {
            return false;
        }

This way the propagation of resizing event back the the rest of the layout of your app is prevented. This reduced the time for switching between two listviews in a contentview (by setting .content= ) from 6 seconds (!!!) to almost nothing. Animations work again and the frame skipping messages are gone, too...

Maybe someone from Xamarin could comment on more tips? Or somebody put an article with all speedup tips? I have some slowness left in my app in other places :)

Best regards,

Hugo


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>