解决 Jetpack Compose 列表滞后问题。

huangapple go评论60阅读模式
英文:

Solution for jetpack compose column lagging issue

问题

使用Jetpack Compose列进行滚动时出现滞后,

Column(
   modifier = Modifier.fillMaxSize(),
   horizontalAlignment = Alignment.CenterHorizontally
) {
   View()
   View()
   View()
   // ...
}

这只是一个示例,但我在真实设备上滚动时遇到滞后问题。

英文:

Scrolling is lagging using Jetpack compose column,

 Column(
    modifier = Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally
) {
  View()
  View()
  View()
  ...
  }

This is sample example but I am facing issue if lagging while scrolling on real devices

答案1

得分: 4

你应该在需要显示许多视图的情况下使用 LazyColumn

这里是这个组件的 示例

还要注意,在 debug 构建中的性能与在具有 isDebuggable = falserelease 构建中的性能非常不同。

如果在发布构建中使用 LazyColumn 仍然遇到性能问题,这里有一篇优化的文章

英文:

You should use LazyColumn in case when you need to display a list of many views.

Here is playground of this component.

Also, note that the performance in a debug build is very different from the performance you will have in a release build with isDebuggable = false

If you run into performance issues despite using a LazyColumn on a release build, here's a great optimization article.

huangapple
  • 本文由 发表于 2023年6月5日 15:02:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76404141.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定