'안드로이드세로모드설정'에 해당되는 글 1건

  1. 2023.03.18 안드로이드 화면 회전(orientation) 가로모드, 세로모드 지정 예제
카테고리 없음2023. 3. 18. 23:04

안드로이드 앱에서 화면을 가로모드, 혹은 세로모드로 고정하거나 센서를 통해 자동으로 변동되게 지정하는 방법이다. 해당 속성은 AndroidManifest.xml 파일에서 지정해줄 액티비티에 지정한다.

액티비티이 screenOrientation 속성에 따른다.

 

 

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:theme="@style/AppTheme.NoActionBar"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:screenOrientation="portrait"> <!-- 요기 --> 
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

 

 

screenOrientation="landspace" -> 가로 고정

screenOrientation="portrait" -> 세로 고정

screenOrientation="fullSensor" -> 기기의 sensor에 따라서 방향이 결정됨

screenOrientation="unspecified" -> 설정하지않으면 적용되는 default. system에 설정된 값에 따라 화면방향 결정

screenOrientation="reversePortrait" 혹은 "reverseLandspace" -> Portrait과 Landspace의 반대 방향으로 각각 설정 됨

screenOrientation="sensorLandspace" -> 기기의 sensor에 따라서, Landspace 혹은 reverseLandscape모드로 설정

screenOrientation="sensorPortrait" -> 기기의 sensor에 따라서, Potrait 혹은 reversePortrait 모드로 설정

screenOrientation="Locked" -> 현재 유저의 rotation값을 그대로 유지

Posted by 사슴영혼'-'