我試圖編寫一個Xamarin.Forms聊天應用程序。 問題是:在Android上,一旦鍵盤顯示整個頁面(包括ActionBar)向上移動。我可以通過使用調整頁面大小的NuGet包來解決IOS上的問題。Xamarin Forms Android鍵盤向上移動整頁
我已經嘗試在Android項目的MainActivity.cs中設置WindowSoftInputMode = Android.Views.SoftInput.AdjustResize
,但它不起作用。 我也嘗試通過重新計算屏幕大小手動調整頁面大小,但是我還沒有找到解決方案來獲取鍵盤大小以便在不同設備上進行精確計算。
有沒有人有過同樣的問題? 是否有適用於所有支持平臺的官方Xamarin.Forms解決方案?
這是迄今爲止我聊天的佈局:
<ContentPage.Content>
<StackLayout Padding="0">
<ScrollView>
<ListView HasUnevenRows="true" x:Name="lvChat" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical" VerticalOptions="Fill" HorizontalOptions="Fill" Padding="5">
<Label Text="{Binding Author, StringFormat='{0}: '}" TextColor="Navy" FontSize="14" />
<Label Text="{Binding Text}" TextColor="Black" FontSize="15" />
<Label Text="{Binding Time}" TextColor="Black" FontSize="14" />
<!-- Format for time.. , StringFormat='{0:HH:mm}' -->
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollView>
<StackLayout Orientation="Horizontal" Padding="0" Margin="5, 5, 5, 5">
<Entry Keyboard="Chat" x:Name="tbxChatInput" HorizontalOptions="FillAndExpand" Placeholder="Send a Message..." />
<Button x:Name="btnSendMsg" HorizontalOptions="End" Text="Send" Margin="5"/>
</StackLayout>
</StackLayout>
提前感謝!