1

我正在尝试为 Surface Duo 构建一个 Xamarin Forms 项目。项目运行,但不会同时使用这两个屏幕。我按照 Xamarin for Surface Duo - Dual-screen | 中的步骤进行操作 微软文档:

  • 更新了指向 SDK 的指针。

  • 添加Xamarin.Forms.DualScreen.DualScreenService.Init(this);mainactivity.cs.

  • 修改了 Activity 缩写以包括:ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.UiMode.

  • 在 Android 应用程序中包含 Xamarin.DuoSdk 包。

  • 在阅读模拟器输出时,一行建议使用 bcdedit 命令关闭 hyper-V,我这样做了。

  • 已选择<build>(Android 10.0 – API 29)

我下载了一些示例(Sketch 360 和双屏演示),但没有让它们同时使用两个屏幕。我运行了 Get 上发布的演示,并更新了软件包,但没有运气。我检查了模拟器中的手机设置,看看是否有启用两个屏幕的设置,但没有找到任何东西。模拟器输出中有一些错误和警告,但不知道如何修复它们。

仿真器输出

emulator: Silencing all qWarning(); use qCWarning(...) instead: QT_LOGGING_RULES=default.warning=false
Failed to open /qemu.conf, err: 2
emulator: INFO: QtLogger.cpp:68: Critical: UpdateLayeredWindowIndirect failed for ptDst=(1283, 327), size=(700x21), dirty=(700x108 0, 0) (A device attached to the system is not functioning.) ((null):0, (null))
emulator: INFO: QtLogger.cpp:68: Critical: UpdateLayeredWindowIndirect failed for ptDst=(1283, 327), size=(700x21), dirty=(700x21 0, 0) (A device attached to the system is not functioning.) ((null):0, (null))
emulator: INFO: QtLogger.cpp:68: Critical: Uncaught TypeError: Cannot read property 'update' of undefined (qrc:/html/js/location-mock-web-channel.js:130, (null))

构建输出

System.InvalidCastException: Unable to cast object of type 'Mono.Debugger.Soft.PointerValue' to type 'Mono.Debugger.Soft.PrimitiveValue'.
System.InvalidCastException: Unable to cast object of type 'Mono.Debugger.Soft.PointerValue' to type 'Mono.Debugger.Soft.PrimitiveValue'.
System.InvalidCastException: Unable to cast object of type 'Mono.Debugger.Soft.PointerValue' to type 'Mono.Debugger.Soft.PrimitiveValue'.
02-06 20:34:52.574 W/libc    ( 3873): Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
02-06 20:34:54.961 W/OpenGLRenderer( 3873): Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
4

2 回答 2

1

如果您询问如何让应用程序以编程方式使用这两个屏幕,而不是用户在启动应用程序后执行操作,则无法完成。

请参阅此处的说明: https ://docs.microsoft.com/en-us/dual-screen/introduction

当用户启动应用程序时,其核心窗口会最大化打开并占据单个屏幕的整个宽度和高度。

用户负责跨越应用程序,这不是应用程序以编程方式进入的状态。

用户始终处于控制之中:为了避免给用户带来不可预测的(或潜在的破坏性)体验,应用程序不应在没有用户有意的操作的情况下自动进入跨接状态。让用户决定。

于 2021-04-01T17:48:10.180 回答
0

Run the Surface Duo Emulator for Visual Studio to start the Surface Duo emulator. If you have any issue about the emulator, you could troubleshoot with the link below. https://docs.microsoft.com/en-us/dual-screen/xamarin/use-emulator?tabs=windows#update-the-pointer-to-your-android-sdk

Install the package via NuGet. Xamarin.Forms.DualScreen:https://www.nuget.org/packages/Xamarin.Forms.DualScreen

Use the xaml like below.

 <dualScreen:TwoPaneView>
    <dualScreen:TwoPaneView.Pane1>
        <StackLayout>
            <Label Text="Pane1 Content" />
        </StackLayout>
    </dualScreen:TwoPaneView.Pane1>
    <dualScreen:TwoPaneView.Pane2>
        <StackLayout>
            <Label Text="Pane2 Content" />
        </StackLayout>
    </dualScreen:TwoPaneView.Pane2>
</dualScreen:TwoPaneView>

Run the project with emulator <build> (Android 10.0 – API 29)

于 2021-03-01T09:42:17.483 回答