将程序更改为动态壁纸
我有一个图形程序,我想将其操作为 liveWallpaper。我浏览了几个教程,看起来它非常适合该模型。
所以我开始了,但很快我意识到 LiveWallpaper 并不像 SurfaceView 那样。
好吧..所以我明白了.. SurfaceHolder obj = getSurfaceHolder();然后是一些处理表面的方法..
有人介意给我快速概述..我对 onSurfaceChaanged()、OnVisibilityChanged、OnSurfaceCreated()、OnSurfaceDestroyed 没有很好的解释。似乎你得到了一个很好的动态壁纸布局,你可以使用一个非常通用的模板并把它们搞出来。
I have a graphical program that I would like to manipulate to liveWallpaper.. I went through a couple of the tutorials and it looked like it fit the mold pretty well.
So I started but soon I realized that LiveWallpaper doesn't SurfaceView.
fine.. so I see.. SurfaceHolder obj = getSurfaceHolder(); then some methods to deal w/ the surface..
anyone mind giving me the quick rundown.. I don't have good explanation for onSurfaceChaanged(), OnVisibilityChanged, OnSurfaceCreated(), OnSurfaceDestroyed. Seems like one you get a good layout for LiveWallpaper you can just use a pretty generic template and crank em out..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用以下代码来绘制壁纸:
使用此代码,您可以按照习惯在画布上绘制。
我个人不会重写 onSurfaceChanged() 和 onSurfaceDestroyed()。我确实重写 onSurfaceCreated() 来开始绘图。如果 LWP 变得可见/不可见,您需要 onVisibilityChanged() 来启动/停止绘图。
I use the following code to paint the wallpaper:
Using this you can draw on a Canvas as you are used to.
I personally don't override onSurfaceChanged() and onSurfaceDestroyed(). I do override onSurfaceCreated() to start drawing. You need onVisibilityChanged() to start/stop the drawing if the LWP becomes visible/invisible.