Prevent Live Wallpaper from changing screen orientation

為{幸葍}努か 提交于 2019-12-12 12:05:42

问题


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.



来源:https://stackoverflow.com/questions/18637213/prevent-live-wallpaper-from-changing-screen-orientation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!