[英]Orientation screen landscape
I'm making a app and it works with the virtual device but when I run this app in an android device just run as a Landscape, does any have any idea why? 我正在制作一个应用程序,并且它可以与虚拟设备一起使用,但是当我在仅以横向模式运行的android设备中运行该应用程序时,有什么想法吗?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); // Our only layout for this app is main.xml
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
an my manifest xml 我的清单xml
<activity
android:name="com.example.colors.MainActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden" >
Add this in manifest: 在清单中添加:
<activity android:name=".YourActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"/>
to fix it permanent 永久修复
remove 去掉
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
and android:configChanges="orientation|keyboardHidden"
和
android:configChanges="orientation|keyboardHidden"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.