Android 自定义视图未正确绘制
我有一个基于 Android Gallery 视图的自定义小部件。它经过稍微定制,可以无间隙地显示视图左侧的元素,并将所需的事件传递给我的侦听器。
在第一个视图布局中,一切都很完美。但是,当我暂停并恢复活动时,视图会冻结。它是可见的,我可以看到 OnTouch() 事件处理程序正在工作,视图位置已调整,但图片没有改变。 Gallery 小部件的 OnDraw() 方法根本没有被调用! 我在这个布局中还有另一个小部件(一个滑动抽屉),只要我几乎不移动抽屉,一切就开始正常工作。
我完全不知道如何解决这个问题。尝试了不同的方法来强制 OnDraw() 方法,但它不起作用。
有什么想法吗?
谢谢
I have a custom widget based on the Android Gallery view. It is slightly customized to show the elements from the left of the view without a gap and pass required events to my listener.
On the very first view layout everything works perfect. However when I pause and resume the activity the view freezes. It is visible, I can see OnTouch() event handlers working, view positions adjusted, but the picture is not changing. The OnDraw() method for the Gallery widget is not called at all!
I have another widget in this layout (a sliding drawer) and as soon as I barely move the drawer everything starts working back again as it should.
I am completely out of ideas how to fix this. Tried different ways to force the OnDraw() method but it is just not working.
Any ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保覆盖
onDraw(android.graphics.Canvas)
而不是OnDraw()
(Canvas
参数和小写首字母“o” ')。如果不是这样,请发布一些代码来查看它。
Make sure you override
onDraw(android.graphics.Canvas)
and notOnDraw()
(both theCanvas
argument and the lower case initial 'o').If it's not that, then please post some code to look at it.