简体   繁体   English

为什么 Android Jetpack 底部导航组件如此滞后?

[英]Why Android Jetpack Bottom Navigation Component is so laggy?

I'm using android bottom navigation component in my app.我在我的应用程序中使用 android 底部导航组件。 As these lines on my MainActivity:正如我的 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. ProductFragment 中有 2 个选项卡使用 viewpager,每个选项卡从服务器加载 REST API 并绑定到 Recyclerview。 I found that everytime I navigate to Product it has about 2 seconds lag until the fragment showed up.我发现每次我导航到 Product 时,它都会延迟大约 2 秒,直到片段出现。 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 .加载 animation 时似乎与 animation 有关,执行和内容加载如recyclerview I did delay the population of the recyclerview some milisecs but that's not a good solution我确实将recyclerview的人口推迟了一些毫秒,但这不是一个好的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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