如何定义屏幕方向在创建活动之前? [英] how to define the screen orientation before the activity is created?

查看:211
本文介绍了如何定义屏幕方向在创建活动之前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定义我的活动只能在纵向模式下:
 机器人:screenOrientation =肖像

I defined my activity to only be in portrait mode by : android:screenOrientation="portrait"

当我需要通过意向相机功能的图片,借此画面在横向模式和保存时,打开屏幕为纵向模式,我回到我的活动一次。我不明白是,我的时间很短的活动是在横向模式下,被销毁,然后在纵向模式下......再建为我的onCreate OND OnRestore中的功能需要一定的时间,等待时间为用户增加一倍..

When I take a picture with the camera function via intent, take this picture in landscape mode and turn the screen to portrait mode when saving it, i return to my activity again. What I dont understand is, that my activity for a short time is in landscape mode, is destroyed and then built again in portrait mode... as my onCreate ond onRestore functions need some time, the waiting time for the user is doubled...

有没有解决办法或别的东西吗?

Is there a workaround or something else?

推荐答案

您也可以注册你的活动,通过添加安卓明确处理任何方向的变化:configChanges =方向到活动定义,然后重写onCofigurationChanged方法在你的活动是这样的:

You can also register your activity to explicitly handle any orientation changes by adding android:configChanges="orientation" to the activity definition and then overriding the onCofigurationChanged method in your activity like this:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

我不知道是否会与您的特定问题的帮助,但我记得这样做时,我想在肖像模式下,只显示一个活动。让我知道,如果它可以帮助:)

I'm not sure if it would help with your specific problem, but I remember doing this when I wanted an activity to only display in portrait mode. Let me know if it helps :)

这篇关于如何定义屏幕方向在创建活动之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆