你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

在应用程序中设置屏幕方向

Azure 通信服务 UI 库使开发人员能够在应用程序中设置屏幕的方向。 可以在呼叫设置屏幕上和 UI 库的呼叫屏幕上指定屏幕方向模式。

先决条件

设置屏幕方向

有关详细信息,请参阅 开源 Android UI 库示例应用程序代码

可用方向

下表列出了 CallCompositeSupportedScreenOrientation 开箱即用配置的类型。 如果您想设置复合屏幕的方向,请将CallCompositeSupportedScreenOrientation设置为CallComposite

方向模式 CallCompositeSupportedScreenOrientation 类型
PORTRAIT CallCompositeSupportedScreenOrientation.PORTRAIT
LANDSCAPE CallCompositeSupportedScreenOrientation.LANDSCAPE
REVERSE_LANDSCAPE CallCompositeSupportedScreenOrientation.REVERSE_LANDSCAPE
USER_LANDSCAPE CallCompositeSupportedScreenOrientation.USER_LANDSCAPE
FULL_SENSOR CallCompositeSupportedScreenOrientation.FULL_SENSOR
USER CallCompositeSupportedScreenOrientation.USER

方向 API

CallCompositeSupportedScreenOrientation 是 Android UI 库的自定义类型。 方向类型的名称是通过与 Android 平台的方向模式名称保持相似来定义的。

默认情况下,设置屏幕方向处于 PORTRAIT 模式,呼叫屏幕处于 USER 模式。 若要为屏幕设置不同的方向,可以传递 CallCompositeSupportedScreenOrientation。 现成的 UI 库包含一组 CallCompositeSupportedScreenOrientation 类型,这些类型可与复合项配合使用。

还可以使用静态函数CallCompositeSupportedScreenOrientation获取类型的列表CallCompositeSupportedScreenOrientation.values()

若要设置方向,请指定 CallCompositeSupportedScreenOrientation 并将其传递给 CallCompositeBuilder。 以下示例中,FULL_SENSOR用于设置屏幕,LANDSCAPE用于复合调用屏幕。

import com.azure.android.communication.ui.calling.models.CallCompositeSupportedScreenOrientation

// CallCompositeSupportedLocale provides a list of supported locales
val callComposite: CallComposite =
            CallCompositeBuilder()
            .setupScreenOrientation(CallCompositeSupportedScreenOrientation.FULL_SENSOR)
            .callScreenOrientation(CallCompositeSupportedScreenOrientation.LANDSCAPE)
            .build()

有关详细信息,请参阅 开源 iOS UI 库示例应用程序代码

可用方向

下表列出了 OrientationOptions 开箱即用配置的类型。 如果您想设置复合屏幕的方向,请将OrientationOptions设置为CallComposite

方向模式 OrientationOptions 类型
portrait OrientationOptions.portrait
landscape OrientationOptions.landscape
landscapeRight OrientationOptions.landscapeRight
landscapeLeft OrientationOptions.landscapeLeft
allButUpsideDown OrientationOptions.allButUpsideDown

方向 API

OrientationOptions 是 iOS UI 库的自定义类型。 方向类型的名称定义时通过保持与 iOS 平台方向模式名称的相似性。

默认情况下,设置屏幕方向处于 portrait 模式,呼叫屏幕处于 allButUpsideDown 模式。 若要为屏幕设置不同的方向,可以传递 OrientationOptions。 现成的 UI 库包含一组 OrientationOptions 类型,这些类型可与复合项配合使用。


let callCompositeOptions = CallCompositeOptions(localization: localizationConfig,
                                                setupScreenOrientation: OrientationOptions.portrait,
                                                callingScreenOrientation: OrientationOptions.allButUpsideDown)
let callComposite = CallComposite(withOptions: callCompositeOptions)

后续步骤