我在Xamarin.Forms應用程序中使用了ZXing.Net.Mobile ZXingScannerView。我使用Android API 21+和Windows Mobile 10對其進行測試。在Android中,相機流完美地擴展到掃描儀視圖的邊界,而UWP則不適用。無論是模擬器的大小還是分辨率。我「以前也嘗試過一個真正的Windows Phone設備,仍然出現問題ZXing.Net.Mobile視圖不會爲Xamarin中的UWP拉伸。表格
我放在ZXingScannerView在類似這樣的內容頁:
<ContentPage.Content>
<StackLayout Spacing="20" Padding="15">
...
<Grid
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<zxing:ZXingScannerView
x:Name="zxing"
Result="{Binding ScannerResult, Mode=TwoWay}"
IsScanning="{Binding ScannerScanning}"
IsVisible="{Binding ScannerVisible}"
IsAnalyzing="{Binding ScannerAnalyzing}"
ScanResultCommand="{Binding ScannedCommand}"/>
<v:MainPageZXingOverlayView />
</Grid>
...
</StackLayout>
</ContentPage.Content>
而且我已經注意到,view .xaml有捕獲元件設置爲伸展= 「填充」
<CaptureElement
Grid.Row="0"
Grid.Column="0"
x:Name="captureElement"
Stretch="Fill" />
// *after* the preview is setup, set this so that the UI layout happens
// otherwise the preview gets stuck in a funny place on screen
captureElement.Stretch = Stretch.UniformToFill;
任何人遇到同樣的問題或有解決辦法嗎?
感謝您的提示。我試過你的建議,但沒有運氣。在同一個源文件中,我看到: 'captureElement.Stretch = Stretch.UniformToFill;' 這是我認爲在UWP中不受尊重的東西,儘管我不知道爲什麼。 – Kalitsov
當我使用600 * 800照相機分辨率時,它在我身邊工作。 –
請注意,我使用'ZXingScannerView'本身,但不是內置的包裝。我已經更新了我的問題,以便更清楚。 – Kalitsov