본문 바로가기

Android(안드로이드)

[Android] 페이지 세로 화면으로 강제 유지하기

> 주제

모든 페이지가 아니라 특정 페이지의 화면을 세로 화면으로 강제 유지하기

 

 

> 환경

OS:

  Windows 10 Home

안드로이드 스튜디오 버전:

  Android Studio Chipmunk | 2021.2.1

 

 

> 방법

AndroidManifest.xml 파일에서

세로 화면으로 보고싶은 화면의 android:screenOrientation을 portrait로 설정한다.

그러면 해당 화면으로 이동 시 세로 화면으로 전환한다.

 

android:screenOrientation="portrait"

 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.myhome.myproject">

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:targetApi="31">
        <activity
            android:name=".PortraitActivity"
            android:exported="false"
            android:screenOrientation="portrait" />

 

 

> 관련글

[안드로이드(Android)] - [Android] 페이지 가로(수평) 화면으로 강제 유지하기

 

 

> 참고

https://developer.android.com/guide/topics/manifest/activity-element