以下是伪代码,用于检测屏幕旋转事件,并决定保留或更改屏幕方向。
public boolean onOrientationChanges(orientation) {
if(orientation == landscape)
if(settings.get("lock_orientation"))
return false; // Retain portrait mode
else
return true; // change to landscape mode
return true;
}
我该如何在Android中制作类似的东西?
编辑: 实际上,我正在寻找有关在哪里处理方向更改的答案。 我不想通过添加screenOrientation =“portrait”来固定方向。
我需要类似于onConfigurationChanges()的东西,可以处理方向,但不需要手动重绘视图。