围绕 addView() 的自定义复合视图线程问题
我一直在研究自定义视图,但在将大量膨胀视图附加到自定义视图(仅扩展 FrameLayout)时遇到了一些严重的 UI 线程阻塞问题。
虽然我尝试将子视图创建从主线程移至后台线程,以至于所有内容都在线程中设置,然后将单个 ViewGroup 添加到活动内容视图中,但这的问题似乎是它不是错开视图的布局和绘制,而是本质上一次性使所有内容失效。
有谁有任何令人震惊的经验或有任何建议如何克服这个问题?
谢谢, 马特
I've been working on a custom view but am having some serious UI Thread blocking issues when attaching a large number of inflated views to tje custom view (which simply extends a FrameLayout).
While I've tried moving the child view creation from the Main Thread into a background thread, to the point that everything is set up in a thread then a single ViewGroup is added to the activities content view, but the problem with this seems to be that rather than staggering the view laying out and drawing, it is essentially invalidates everything in one go.
Does anyone have any experience of staggering this or have any suggestions how to overcome this issue?
Thanks,
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能否发布更多详细信息,以便我们了解为什么
View
创建需要这么长时间?我不相信你能扭转这一局面。 Pre-Honeycomb 使
ViewGroup
失效导致整个子层次结构重新绘制:(请参阅这个精彩的 I/O 演讲 了解更多详细信息。
Can you post more details so that we can understand why the
View
creation is taking so long?I don't believe that you can stagger this. Pre-Honeycomb invalidating a
ViewGroup
caused the entire child hierarchy to re-draw :(See this great I/O talk for more details.