找到你要的答案

Q:Android emulator force landscape on start-up

Q:Android模拟器启动时强制景观

I have correctly configured application, which runs in landscape only. When I run it on Emulator (v.24.4.0.0), the Android starts in portrait mode. Application runs in landscape, but picture is rotated and header of window is hidden, because in portrait mode emulator does not fit. I can rotate it by LeftCTRL + F12. Next I can press Alt + Space a choose Move to show whole window, but it is not nice.

If you could help me to force the default orientation as landscape, you make me happy : )

In Emulator and AVD Manager I don't see any settings, where I could make this preference. Config.ini in my avd directory contains:

hw.initialOrientation=landscape

Thank you!

我已经正确配置应用程序,只运行在景观。当我运行在模拟器(v.24.4.0.0),Android在肖像模式开始。应用程序运行在风景中,但图片是旋转和窗口的标题隐藏,因为在纵向模式模拟器不适合。我可以把它旋转leftctrl + F12。接下来我可以按ALT +空间选择移动到显示整个窗口,但它是不好的。

如果你能帮我把默认的方向作为风景,你让我高兴:

在仿真器和AVD管理我没有看到任何的设置,在那里我可以让这种偏好。Config.ini在我的AVD目录包含:

hw.initialOrientation=landscape

谢谢您!

answer1: 回答1:

In AVD Manager, use "Edit" button and choose another device, labeled as "tablet", which is landscape by default. Note screen dimensions, where X should be greater than Y.

If none of predefined devices satisfy your needs, you can switch to the "Device definitions" tab of AVD Manager and create your own device. I prefer light screens e.g. 800x480 which are emulating faster. Then use "Create AVD" button to define new emulator instance.

在AVD管理,使用“编辑”按钮,选择另一个装置,称为“平板”,这是默认的景观。注意屏幕尺寸,其中x应该大于Y.

如果预定义的设备没有满足你的需要,你可以切换到AVD管理“设备定义”选项卡,创建你自己的设备。我喜欢轻如屏幕800X480,仿真速度更快。然后使用“创建AVD”按钮来定义新的模拟器。

answer2: 回答2:

In your activity before setcontentview();

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

paste this...hope this will work..

在活动前setcontentview();

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

粘贴此…希望这将工作..

answer3: 回答3:

If you want to have fixed orientation for your activities then you can use-

android:screenOrientation="portrait"

as an attribute to that activity in that manifest. But if you want to set the orientation in runtime depending upon what was the previous orientation while launching the application, you need to check for the previous orientation in onCreate() and then set it to that value programmatically there itself using setRequestedOrientation() in the activity

Sometimes emulator doesn't work perfectly, So use real device for accurate result.

如果你想有固定的方向,那么你可以使用你的活动—

android:screenOrientation="portrait"

作为该清单中该活动的属性。但如果你想设置定位在运行时根据以往的定向发射时应用程序是什么,你需要检查在oncreate()上定位并将该值设置为活动中以编程方式使用setrequestedorientation()存在本身

有时仿真器不完美,所以使用真实的设备来获得准确的结果。

answer4: 回答4:

Set orientation on your android mainfest:

    <activity
        android:name=".Android_mobile_infoActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>

设置定位在你的Android美茵节:

    <activity
        android:name=".Android_mobile_infoActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
android  android-emulator  landscape-portrait