下拉式框架落下和滞后在JetPack组成
所以我现在在泡菜里。
我有
我有国家的列表,我想允许用户通过显示下降菜单来选择它们,而早些时查看说view.setupdropdown
,此inturn加载list popupupwindow
并将其固定在当前视图中,并显示所有项目,并且在没有jank或jank或jank或任何框架下降。
喜欢
val dropDown = ListPopupWindow(context)
dropDown.setAdapter(
ArrayAdapter(
context,
android.R.layout.simple_spinner_dropdown_item,
list.map { itemFormatter(it) })
)
并显示它,或者我可以使用自定义
泡菜,
所以现在我在jetpack构图中建立了相同的体验,并使用dropdownmenu
,它加载了所有这些项目列
在项目数量较少时正常工作,但是,当涉及大量项目时,列表的列表却更多的100个项目会删除几帧,并显示<代码>弹出延迟后。
我查找内部,并试图用列
用lazycolumn
将所有这些文件中的所有这些文件复制到示例项目中 固有的测量值尚未支持子组件
,并且会引发和异常和失败。
DropdownMenu(
toggle = toggle,
expanded = showMenu,
onDismissRequest = { onDismiss() },
) {
options.forEach{ item ->
DropdownMenuItem(onClick = {
onDismiss()
}) {
Text(text = item)
}
}
}
如果我使用Modifier modifier.height(200.dp).widht(300.dp)
我查找 ,如果我将固定高度和宽度应用于lazycolumn
,它的工作正常非常好。在问题跟踪器中,并找到了此问题我在上面做了什么。
不确定在这里使用什么,因为撰写仍然是新的,不知道哪个组件适合该账单。
So I am bit of in a pickle now.
The Begining
I have list of countries and I want to allow the user to pick any of them by showing a drop a down menu, and earlier no jetpack compose way, I had a an extension on View
say View.setupDropDown
and this inturn loads up a ListPopupWindow
and anchors it to the current view, and shows all the items and works perfectly fine without jank or any frame drop.
like
val dropDown = ListPopupWindow(context)
dropDown.setAdapter(
ArrayAdapter(
context,
android.R.layout.simple_spinner_dropdown_item,
list.map { itemFormatter(it) })
)
and show it, or I can use a custom
The Pickle
So now I am building the same experience in Jetpack Compose, and Using DropDownMenu
and it loads up all those items in a Column
which works fine when Items are less in number, but, when it comes to large number of items like, a list which has more then 100 items, it drops a few frames, and shows the PopUp
after a delay.
I looked up insides and tried to replace the Column
with LazyColumn
by copying in all those files to a sample project but that doest work asIntrinsic measurements is not yet supported for the Subcomposables
and it throws and exception and fails.
DropdownMenu(
toggle = toggle,
expanded = showMenu,
onDismissRequest = { onDismiss() },
) {
options.forEach{ item ->
DropdownMenuItem(onClick = {
onDismiss()
}) {
Text(text = item)
}
}
}
It works perfectly fine If I apply fixed height and width to the LazyColumn
, using the modifier Modifier.height(200.dp).widht(300.dp)
I looked up in issue tracker, and found this issue which was relevant but not same, and the suggestion was to do what I did above.
Not sure what to use in here, as Compose is still new, don't know which component fits the bill.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新:有一个问题跟踪器报告。
您可以尝试内部也有效的解决方案(如果您还没有懒惰的列)
先前的答案
可能有点晚了,但是我发现这篇文章
对我有用。
将来在此处添加代码:
用法:
Update: There is an issue tracker report on this.
You can try the solution inside which also works (if you don't already have a lazy column)
Previous answer
It may be a little late but I found this post
That worked for me.
Adding the code here for the future:
Usage: