Android 动态壁纸问题
我今天一直在摆弄动态壁纸,你知道吗,我就是无法让它工作。
我决定提出尽可能最简单的动态壁纸并从那里开始构建,但即使这样也出了问题!这就是我的壁纸服务类的组成,
@Override
public Engine onCreateEngine() {
return new SimpleEngine();
}
public class SimpleEngine extends Engine {
@Override
public void onSurfaceCreated(SurfaceHolder holder) {
super.onSurfaceCreated(holder);
Canvas c = holder.lockCanvas();
Paint paint = new Paint();
paint.setColor(Color.BLUE);
c.drawCircle(50, 50, 50, paint);
}
}
我想要测试的是是否可以在屏幕上出现一个小圆圈,但是当我将其设置为我的壁纸时,它只是说“正在加载动态壁纸...”并且没有不让步(但它也不会冻结)。代码正在被调用,但我不确定出了什么问题。
有人可以帮我指出吗?
I'v been tinkering with Live Wallpapers today and wouldn't you know it, I just can't get it to work.
I decided to come up with the most simple live wallpaper possible and build from there but even that is going wrong! This is what my WallpaperService class consists of,
@Override
public Engine onCreateEngine() {
return new SimpleEngine();
}
public class SimpleEngine extends Engine {
@Override
public void onSurfaceCreated(SurfaceHolder holder) {
super.onSurfaceCreated(holder);
Canvas c = holder.lockCanvas();
Paint paint = new Paint();
paint.setColor(Color.BLUE);
c.drawCircle(50, 50, 50, paint);
}
}
All I wanted to test was if I could make a little circle appear on the screen, but when I go to set it as my wallpaper it just says "Loading live wallpaper..." and doesn't budge (but it doesn't freeze either). The code is getting called but I'm not sure whats going wrong.
Could someone point it out for me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你最后缺少 SurfaceHolder.unlockCanvasAndPost
I guess you are missing SurfaceHolder.unlockCanvasAndPost at the end