I tried to write a Xamarin.Forms chat application. Problem: On Android, as soon as the keyboard displays the entire page (including the ActionBar), it moves up. I can fix the problem on iOS using the NuGet package, which resizes the page.
I have already tried setting WindowSoftInputMode = Android.Views.SoftInput.AdjustResize to MainActivity.cs in an Android project, but this did not work. I also tried changing the page size manually by recounting the screen size, but I did not find a solution to get the keyboard size for accurate calculation on different devices.
Has anyone had the same problem before? Is there an official Xamarin.Forms solution for all supported platforms?
This is my chat layout:
<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" /> </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>
Thanks in advance!
source share