내 보기에 안드로이드 앱 가로 모드 비활성화합니다 중 일부에 대해 어떻게 해야 합니까?
,,, = " portrait" < /code> 안드로이드 스리노리엔테이션 code> < 추가 활동에 대한 안드로이드마니페스트리스 레비 예를 들면 다음과 같습니다.
<activity android:name=".SomeActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" />
편집: 이 때문에, 내가 느끼는 것은 매우 드문 것으로 유죄 답변 된 슈퍼 인기 강요하는 데 가장 적합한 솔루션을 적용, s # 39 세로 it& 문제가 자주 to.< br>; 주요 인물 함께 경고를 했다.
그래서 대부분의 응용 소프트웨어, 물리적 구성 그냥 전화인가 센서, 자신의 결정을 할 수 있도록 하는 사용자가 방법에 대한 몇 가지 경우 해당 앱을 상호 작용할 수 있지만, 아직도 할 경우 you& 생각할 수 있습니다. # 39 에서 기본 방향 센서 ',' re in your 행복하지 비헤이비어에 览侩 荤례:
이 ',' 자신의 매니페스트 파일 추가 안드로이드 스리노리엔테이션 = " portrait" 어디 선언해야 이런 활동.
<activity android:name=".yourActivity"
....
android:screenOrientation="portrait" />
If you want to do java 코드를 사용하여 시도하시겠습니까
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
'네' 방법 '에서 활동 전에 세콘텐트비에프 전화하시기 언크리치 ()'.
이 모든 도움말 및 쉽게 이해할 수 있다.
여기에 대답을 많이 사용할 수 있는 ',' 안드로이드마니페스트리스메르 파일, portrait" " 제안하고 있습니다. 그러나 명시된 것처럼 보이는 이 권능은하나님께 좋은 솔루션이 있을 수 있는 장치를 기여한 문서, 틀렸다니까 아웃해야 가로방향입니다. 또한 특정 장치 (사용할 수 있는 최고의 가로방향입니다) 밖에 얻지 못한 초상화, 올바른 방향 들어갈 예정이다.
대신, ',' 내 제안에 " nosensor" 사용할 수 있습니다. 이렇게 하면 해당 기본 남겨두십시오 장치가 사용할 수 있는 기본 방향, 구글 플레이 및 구매 저지할 않습니다 / 다운로드를 통해 센서 doesn& 엉망하지 up your (드크, 내 경우에는), t # 39 게임이다.
이런 환경에서 추가하기만 분명히 선
>. 안드로이드 스리노리엔테이션 = " portrait";
<manifest
package="com.example.speedtest"
android:versionCode="1"
android:versionName="1.0" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="ComparisionActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
',' 의 안드로이드마니페스트리스메르 sensorPortrait" 안드로이드 스리노리엔테이션 = " 변경해야 합니다.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// rest of your code......
}
이 클래스는 전체 작업 대신 잠금식 방향 방향 보는 중 하나에서 잠급니다 실용적으로 동적으로 사용할 수 있습니다 -
원하는 대로 보기입니다 가로방향입니다
OrientationUtils.lockOrientationLandscape(mActivity);
OrientationUtils.lockOrientationPortrait(mActivity);
OrientationUtils.unlockOrientation(mActivity);
방향 Util 클래스
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Build;
import android.view.Surface;
import android.view.WindowManager;
/* * This class is used to lock orientation of android app in nay android devices
*/
public class OrientationUtils {
private OrientationUtils() {
}
/** Locks the device window in landscape mode. */
public static void lockOrientationLandscape(Activity activity) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}
/** Locks the device window in portrait mode. */
public static void lockOrientationPortrait(Activity activity) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
/** Locks the device window in actual screen mode. */
public static void lockOrientation(Activity activity) {
final int orientation = activity.getResources().getConfiguration().orientation;
final int rotation = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
.getRotation();
// Copied from Android docs, since we don't have these values in Froyo
// 2.2
int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8;
int SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9;
// Build.VERSION.SDK_INT <= Build.VERSION_CODES.FROYO
if (!(Build.VERSION.SDK_INT <= Build.VERSION_CODES.FROYO)) {
SCREEN_ORIENTATION_REVERSE_LANDSCAPE = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
SCREEN_ORIENTATION_REVERSE_PORTRAIT = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}
if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) {
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
} else if (rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270) {
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
activity.setRequestedOrientation(SCREEN_ORIENTATION_REVERSE_PORTRAIT);
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
activity.setRequestedOrientation(SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
}
}
}
/** Unlocks the device window in user defined screen mode. */
public static void unlockOrientation(Activity activity) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
}
}
안드로이드 앱 '' 비활성화하려면 가로 모드 단축시킵니다 (또는 단일 활동) 가 추가, all you need to do
다음과 같습니다.
<activity android:name="YourActivityName"
android:icon="@drawable/ic_launcher"
android:label="Your App Name"
android:screenOrientation="portrait">
이렇게 하려면 프로그래밍 방식으로 ie. java 코드를 사용하여. 그렇게 할 수 있습니다 다음 코드를 추가하여 Java 클래스에 # 39, t want to be 활동에 너회가 don& 표시되려면 가로방향입니다 모드.
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
자세한 내용은 여기 dell. 이퍼 발달장애인지원법은 큰 도움이 될 수 있습니다. [enter https://partner. 여기에 설명을] [1]
[1]: https://developer.android.com/reference/android/R.styleable.html # AndroidManifestActivity_screenOrientation
각 활동 방향을 설정해야 합니다.
<activity
android:name="com.example.SplashScreen2"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name="com.example.Registration"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name="com.example.Verification"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name="com.example.WelcomeAlmostDone"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name="com.example.PasswordRegistration"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
</activity>
항상 고객의 특정 활동에 의해 강제로 지정할 수 있습니다 이 글을 쓰는 in your 마니페스트리스메르 남아 세로 모드
<activity android:name=".MainActivity"
android:screenOrientation="portrait"></activity>
또한 사용자의 활동을 지속적으로 유지하는 데 힘을 써서 다음과 같은 줄을 포스트레이트 모드 s 언크리치 () 메서드를 너회의 activity& # 39.
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
[Activity(MainLauncher = true, Icon = "@drawable/icon", ScreenOrientation = ScreenOrientation.Portrait)]
또 다른 솔루션을 적용할 수 없는 클래스 위에 제대로 거의 비슷한 전역으로라는 배치해야 하는 활동 및 각 헤더입니다.
이 모든 활동을 할 수 있는 확장 할 필요 없이 응용 프로그램 전반에 대한 공통 기본 클래스.
는 이 프로젝트의 첫 해트트릭을 포함 하위 애플리케이션과는 합니다. 이 경우, 먼저 시작될 언크리치 () 라는 앱을 등록할 스티브 티라이프키클레카예브랙스 객체에는 apiu 수준 14+) 알림을 받을 수 있는 활동 주기 이벤트.
따라서 자신의 코드를 실행할 수 있는 기회를 활동 때마다 in your app 시작됨인 (또는 중지 또는 재개됨 또는 있는모든). 이 시점에서 세르케스트도리엔테이션 문의할 수 있습니다 () 에 새로 만들어진 활동까지입니다.
App name = " .MyApp" 추가할 것을 잊지 마십시오.;; 자신의 매니페스트 파일.
class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
// register to be informed of activities starting up
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity,
Bundle savedInstanceState) {
// new activity created; force its orientation to portrait
activity.setRequestedOrientation(
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
....
});
}
}