如何在创建活动之前定义屏幕方向?
我将我的活动定义为仅处于纵向模式: android:screenOrientation="portrait"
当我通过意图使用相机功能拍照时,以横向模式拍摄这张照片并在保存时将屏幕切换为纵向模式,我再次返回到我的活动。我不明白的是,我的 Activity 短时间内处于横向模式,被销毁,然后以纵向模式再次构建...由于我的 onCreate 和 onRestore 函数需要一些时间,用户的等待时间增加了一倍..是否
有解决方法或其他方法?
I defined my activity to only be in portrait mode by :
android:screenOrientation="portrait"
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以注册您的活动以显式处理任何方向更改,方法是将
android:configChanges="orientation"
添加到活动定义中,然后重写活动中的 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: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 :)
将
android:configChanges="orientation"
添加到您的
标记中。这样,活动将不会在方向更改时重新创建,而只会收到回调onConfigurationChanged
,您可以忽略该回调。Add
android:configChanges="orientation"
to your<activity>
tag. This way the activity will not be recreated on orientation change, but will just receive a callbackonConfigurationChanged
which you can ignore.