Skip to content Skip to sidebar Skip to footer

Android Screen Orientation Mixing Up

My android application is designed to be landscape-only. I have put android:screenOrientation='landscape' android:configChanges='orientation|keyboardHidden|screenSi

Solution 1:

I spent days on this same problem. As other posters revealed, when returning from sleep/lock screen, the app is handed the same portrait mode that the lock screen has. The real find was that it goes through onResume() and onWindowFocusChanged twice - once for the portrait mode, then for the landscape mode. I used the following code in both onResume() and onWindowFocusChanged() to check before executing screen initializations:

int gW = view.getMeasuredWidth();
int gH = view.getMeasuredHeight();
if (gW > gH) {// landscape!// the height will be set at this point// so reinitialize your screen here
}

It helped me. Hope this helps you.

Solution 2:

no you cannot.

If you want to get view sizes you can override the onLayout http://developer.android.com/reference/android/view/View.html#onLayout(boolean, int, int, int, int)

Post a Comment for "Android Screen Orientation Mixing Up"