浏览了几篇关于配置和方向更改的帖子和线程,但我仍然不清楚。
如onConfigurationChanged
仅在 orientation
时被调用更改自 landscape
至portrait
或 portrait
至landscape
(顾名思义),但是有什么办法可以听reverseLandscape
或reversePortrait
通过任何 api 级别的任何种类的列表器更改方向。
或者可以听一下rotation
变化与 onConfigurationChanged
相同??
任何帮助都将受到高度赞赏!!
最佳答案
您可以使用加速度计和磁场传感器来计算设备旋转,然后调用
getWindowManager().getDefaultDisplay().getRotation();
当旋转达到一定值时。计算旋转的方法在我的回答How to measure the tilt of the phone in XY plane using accelerometer in Android
关于android - 如何通过任何监听器跟踪反向方向(reverseLandscape 和reversePortrait)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15448526/