prevent更改屏幕方向动态壁纸 [英] Prevent Live Wallpaper from changing screen orientation

查看:199
本文介绍了prevent更改屏幕方向动态壁纸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个动态壁纸,我想在纵向模式下始终保持它。我知道这是可能的一个活动申报清单中的方向,但我不能找到一种方法,做同样的一个动态壁纸的服务。是否有可能以某种方式告诉墙纸引擎交换在渲染过程中或类似的东西的X和Y轴,因为我不知道了。

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.

推荐答案

使用下面的方法来检查方向更改

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.

要确保你现在把X作为y和y为x。
同样适用于宽度和高度。

Be sure that you now treat x as y and y as x. Same goes for width and height.

这篇关于prevent更改屏幕方向动态壁纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆