-1

I started to profile my apps startup, and looks like side drawer com.google.android.material.navigation.NavigationView takes quite a lot of time to inflate.

As the NavigationView is hidden when the app is started, I think it should be ok to delay it's inflation.

I tried to check ViewStub or AsyncLayoutInflator approach, but sill did not find nay usable way to make this work.

Is somebody successfully initializing NavigationView asynchronously?

Update:

I use vector drawable icon in NavigationView menu items. Looks like those are the bottle neck here. Vector paths are not anything complex, maybe I try to simplify them or go with the png's...

devha
  • 3,307
  • 4
  • 28
  • 52
  • NavigationView is working fine to me ... maybe you added to much to it .. fx ImageViews without loading images in backgound ... it's hard guess what is wrong with your code without it – Selvin Nov 09 '19 at 16:26

1 Answers1

0

Is there anything that needs to be loaded from network in your navigation view? If yes, you can use view models to do so and host your data in hosting activity connected to that view model. Doing this you will NOT be able to speed up the initialization of navigation drawer but would be able to retain the data needed to populate it so next time it won't take that long. This way you can also defer the network operations until navigation drawer is being opened for the first time.

If you're not making any network calls to load data in nav drawer and still it's taking too long, there must be something terribly wrong with the way it's being populated.

ked
  • 79
  • 5
  • Looks like the vector drawables are the bottle neck here (updated the original question). – devha Nov 09 '19 at 20:48