简体   繁体   中英

Why Android Jetpack Bottom Navigation Component is so laggy?

I'm using android bottom navigation component in my app. As these lines on my MainActivity:

BottomNavigationView navView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.navigation_home,
                R.id.navigation_product,
                R.id.navigation_setting
).build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(navView, navController);

There are 2 tabs inside ProductFragment using viewpager and each tabs load REST API from the server and bind to Recyclerview. I found that everytime I navigate to Product it has about 2 seconds lag until the fragment showed up. Is there any work around for the lag?

I'm having the same problem. It seems something to do with the animation when loading animation is execute and content loading like recyclerview . I did delay the population of the recyclerview some milisecs but that's not a good solution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM