문제

누군가가 자신의 응용 프로그램을 세로 모드로 잠그는 방법을 알려줄 수 있습니까?그것은 매니페스트 파일에서 간단한 구성입니까?

도움이 되었습니까?

해결책

Yes. Add android:screenOrientation="portrait" to the manifest under your main activity.

<activity android:name=".yourActivity" android:screenOrientation="portrait"... />

다른 팁

Yes! It's an attribute of the activity tag:

<activity android:name=".yourActivity" android:screenOrientation="portrait" ... />

Also, you may have to add the following to your activity element:

android:configChanges="keyboardHidden"

That way, the OS won't change the orientation when the user opens a sliding keyboard.

None of these answers worked on my system but I did find the following worked perfectly for a simple app that I developed:

Within MainActivity.java add:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

to onCreate ()

This is mine:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

I know that it is not (always) best practice locking orientation, but in special circumstances it is valid and I only want this temporarily while I continue developing.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top