문제

I making an app and im currently optimizing it to Samsung Galaxy Tab. I have a little problem here, when i launch the application, it is came up in only one portrait orientation.

I use this code:

android:screenOrientation="portrait"

It is only working with one portrait screen orientation, so if i rotate the device to upside down, its now changing. Its a little annoying, because if i start the application in the wrong orientation, my app came up in upside down and wont change.

What can i do with this ?

도움이 되었습니까?

해결책

You can try Activity. setRequestedOrientation(int)

The parameter can be either ActivityInfo.SCREEN_ORIENTATION_PORTRAIT or ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT

다른 팁

Instead of setting android:screenOrientation="portrait" , you should set android:screenOrientation="sensorPortrait" if you are on API Level 9+.

For more info: check documentation.

In onCreate() before calling super.onCreate() call below method... it should work...

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top