Reputation: 11053
I am working on an app where all activities are set to:
android:screenOrientation="portrait"
Here is what happens:
Tablet is in portrait mode BEFORE the app starts:
And this is what happens when the tablet is in landscape mode when the app starts:
How can I avoid this creation in LANDSCAPE mode for a fraction of a second and immediately be created in portrait mode only?
Many thanks
Upvotes: 1
Views: 290
Reputation: 9058
Add in your manifest in the activity tag: android:configChanges="orientation". Now it will not restart in the orientation.
This is a theory only, but if you see your screen in landscape mode first you you can perhaps override your root view and override the onDraw method. Check your canvas width and height. If the height is bigger smaller than width don't draw or set visibility false. Until you receive the "right" canvas to draw upon.
It might be an overkill but I think it might be done.
Also look for more possible things that can change screen orientation here: http://developer.android.com/guide/topics/manifest/activity-element.html#screen
There is another one from API 14 and up (I think) that caused me a lot of problem which is "ScreenSize".
Upvotes: 1
Reputation: 12346
Create your Activity in portrait mode and change to landscape mode in the onResume
method.
myActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Upvotes: 0