我想改变方向以编程方式在运行我的Android应用程序,用code这几行:
I want to change the orientation programmatically while running my Android App, with these lines of code:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
他们的工作,到目前为止,但主要的问题是,整个活动被重新装载时,屏幕方向改变了,我不希望出现这种情况。可能吗?谢谢你。
They work so far, but the main problem is that the whole activity is reloaded when the screen orientation changes, and I don't want that. Is it possible? Thanks.
编辑:好了,以后我当我发现我失踪了。我在configChanges财产必须还包括屏幕尺寸,所以有
android:configChanges="orientation|screenSize"
解决了整个事情。
请参阅编辑由@luisfer。对于那些针对安卓3.2及以上版本,你既需要
See the edit by @luisfer. For targeting Android 3.2 and above, you need BOTH
android:configChanges="orientation|screenSize"
http://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange
上一篇:与工具栏的Android 5.0的材料标签工具栏、标签、材料、oid
下一篇:GoogleApiClient抛出"尚未连接&QUOT GoogleApiClient;后onConnected函数获取调用抛出、函数、GoogleApiClient、onConnected