首页 > 解决方案 > 为什么 Android Jetpack 底部导航组件这么卡?

问题描述

我在我的应用程序中使用 android 底部导航组件。正如我的 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);

ProductFragment 中有 2 个使用 viewpager 的选项卡,每个选项卡从服务器加载 REST API 并绑定到 Recyclerview。我发现每次我导航到 Product 时,它都会延迟大约 2 秒,直到片段出现。是否有任何解决滞后的方法?

标签: javaandroidandroid-jetpack

解决方案


我有同样的问题。执行加载动画和加载内容时,它似乎与动画有关recyclerview。我确实延迟了recyclerview一些毫秒的人口,但这不是一个好的解决方案


推荐阅读