【问题标题】:Screen goes black for a while if camera orientation is changed如果更改相机方向,屏幕会变黑一段时间
【发布时间】:2012-06-21 13:32:32
【问题描述】:

在将设备 orientation纵向更改为横向横向更改为纵向时,它正在发生。我面临的问题是从一种模式更改为另一种屏幕时黑了一会儿。似乎重新创建了活动。

我使用了android:configChanges,但在以编程方式显示视图方向之后,我无法更改。

更改相机模式时如何避免黑屏?

【问题讨论】:

    标签: android android-orientation


    【解决方案1】:

    重新创建活动后,它会执行您在onCreate() 中请求的所有操作。

    如果您使用的是 Activity,那么您应该考虑将 onRetainNonConfigurationInstance() 用于您的 Activity 中的重物。

    但请记住,onRetainNonConfigurationInstance() 现在已弃用。

    如果您对 Fragments 感到满意,那么您应该改用 setRetainInstance(boolean)。

    以下链接将对您有所帮助。

    http://developer.android.com/resources/articles/faster-screen-orientation-change.html http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/Fragment http://android.codeandmagic.org/2011/07/android-fragments-saving-state-and-screen-rotation/

    【讨论】:

    • ,感谢您的回复。但我无法解决问题。在我的清单中,我给出了 android:configChanges="keyboardHidden|orientation"。
    • 在surfacecreated()和surfacechange()中我给出了:parameters.set("orientation", "portrait"); camera.setDisplayOrientation(90); parameters.setRotation(90);//纵向和横向角度为零。
    • 什么是设备操作系统版本?如果您的目标是 sdk 13,请尝试使用 android:configChanges="orientation|screenSize"
    猜你喜欢
    • 1970-01-01
    • 2012-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多