我目前正在研究一個非常密集的活動壁紙,並且不能很好地處理屏幕旋轉。動態壁紙屏幕旋轉
事實上,壁紙被破壞,並顯示一個空白的屏幕,而無需調用onSurfaceChanged!
這是我有onSurfaceChanged方法中:
@Override
public void onSurfaceChanged(SurfaceHolder holder, int format,
int width, int height) {
// TODO Auto-generated method stub
super.onSurfaceChanged(holder, format, width, height);
mRatio = (float) width/height;
if (mRatio > 1) {
orientation = 0;
}
if (mRatio < 1) {
orientation = 1;
}
setRunning(true);
Log.i(TAG, "Screen Rotation...");
mHandle.post(r);
}
我肯定這種方法不會被調用,因爲沒有日誌消息。
爲什麼會發生這種情況,以及處理屏幕旋轉的一些技巧是什麼? 難道是我的動態壁紙是如此密集的虛空不能被稱爲?
此外,onVisibilityChanged不叫,以及當我打開模擬器的應用程序,也沒有日誌消息:
@Override
public void onVisibilityChanged(boolean visible) {
// TODO Auto-generated method stub
super.onVisibilityChanged(visible);
if (visible) {
setRunning(true);
Log.i(TAG, "Visible...");
mHandle.postDelayed(r, 2000);
} else {
setRunning(false);
Log.i(TAG, "Invisible...");
mHandle.removeCallbacks(r);
}
}
你能發佈更多的代碼嗎?需要知道所有繁重的工作在哪裏完成。在我的動態壁紙中,onSurfaceChanged和onVisibilityChanged在屏幕旋轉期間被調用。此外,在方向更改期間,請檢查LogCat中的「超時等待牆紙偏移」。 – Ole