I'm working on a Live Wallpaper and I would like to keep it always in portrait mode. I know it's possible for an Activity to declare the orientation in the Manifest, but I can't find a way to do the same with a live wallpaper service. Is it possible somehow to tell the Wallpaper Engine to swap the x and y axis in the rendering process or something similar, because I have no idea anymore.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Use the following method to check for orientation changes
public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height)
If width is greater than height you know that the orientation changed to landscape.
Be sure that you now treat x as y and y as x. Same goes for width and height.
回答2:
You have handle the orientation change for live wallpaper. you can't fix the orientation.