안녕하세요. nativescript에서 기기 방향을 설정하는 방법을 알고 싶습니다. 특히, 필자는 동일한 방향 (세로 방향)을 유지하면서 글자를 쓰고있는 응용 프로그램을 항상 회전시켜 장치를 회전시키지 않아도 가로 방향으로 들어가기를 원합니다.nativescript에서 방향을 설정하는 방법
nativescript-orientation 플러그인과 setOrientation을 사용해 보았습니다. 목록 플러그인
내가 정의의 속성 setOrientation을 읽을 수 없습니다 "라는 오류를 얻을 그러나var orientation = require('nativescript-orientation');
console.log(JSON.stringify(orientation));// outputs JS: {}
orientation.setOrientation("portrait");
. TNS는. 또한 나는 platforms/android
디렉토리를 제거하고 동일한 결과 tns platform add android
를 실행하려고 플러그인이 설치되어 있는지 보여줍니다.
나는 또한 성공하지의 AndroidManifest.xml에 android:screenOrientation="portrait"
의 다양한 조합을 가하고 시도.
의 AndroidManifest.xml을 App_resources이
처럼 보이는 내부에서<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="__PACKAGE__"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="__APILEVEL__"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:screenOrientation="portrait"
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.tns.NativeScriptActivity"
android:label="@string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
</manifest>
을 완성 했습니까? '빌드'를 완료 했습니까? 또한 장치/에뮬레이터에있는 현재 .apk를 제거한 다음 새 빌드를 '실행'또는 'livesync'해야 할 가능성이 높습니다. 매니페스트 옵션은 안드로이드 앱의 방향을 내가 아는 바대로 강제하는 더 나은 대안입니다. 그래서 작동하지만 오래된 .apk를 제거하지 않았다면 장치에 캐싱 문제가있을 수 있습니다 :) –
apk를 삭제하고'tns run android'를 사용하여 실행합니다. 또한 안드로이드 manifest.xml을 추가했습니다. 뭔가를 놓친 경우 – xerotolerant