2016년 11월 16일 수요일

Tip - 화면 방향 고정

보통 스마트폰은 방향에 따라 가로형이나 세로형으로 바뀝니다.
그러나 가끔 가로형 또는 세로형중 한가지로 고정시켜서 프로그램을 해야 할 때가 있죠.
안드로이드 프로그램일 경우 다음과 같이 Attribute를 수정하면 됩니다.

using Android.Graphics;
using Android.Content.PM;
using System.Collections.Generic;

namespace TouchTest.Droid
{
    [Activity (Label = "TouchTest.Droid", MainLauncher = true, Icon = "@drawable/icon",
               ScreenOrientation = ScreenOrientation.SensorLandscape)]
    public class MainActivity : Activity
    {

만약 이 부분을 ScreenOrientation.Landscape로 한다면, 스마트폰을 뒤집었을때 다음과 같이 그려집니다.





그러나 ScreenOrientation.SensorLandscape로 한다면 다음과 같이 나오죠





댓글 없음:

댓글 쓰기