我的观点是,当我打开手机的键盘时,它会随所有东西和顶部栏一起完全移动,我需要从包含聊天功能的应用中确定顶部栏是固定的,并且只有当键盘打开,消息就会移动。
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:common="clr-namespace:HomieApp.Views.Common;assembly=HomieApp"
xmlns:app="clr-namespace:HomieApp;assembly=HomieApp"
xmlns:helpers="clr-namespace:HomieApp.Helpers;assembly=HomieApp"
xmlns:forms="clr-namespace:Lottie.Forms;assembly=Lottie.Forms"
x:Class="HomieApp.Views.Servicio.ChatPage">
<ContentPage.Resources>
<ResourceDictionary>
<DataTemplate x:Key="leftChatTemplate">
<ViewCell>
<common:ChatLeftMessageItemTemplate />
</ViewCell>
</DataTemplate>
<DataTemplate x:Key="rightChatTemplate">
<ViewCell>
<common:ChatRightMessageItemTemplate />
</ViewCell>
</DataTemplate>
<helpers:ChatDataTemplateSelector x:Key="chatDataTemplateSelector"
LeftChatTemplate="{StaticResource leftChatTemplate}"
RightChatTemplate="{StaticResource rightChatTemplate}" />
</ResourceDictionary>
</ContentPage.Resources>
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<common:MainLabelNavigation
Grid.Row="0"
HorizontalOptions="FillAndExpand"
x:Name="bar"
IsVisibleMenu="True"
Clicked="Bar_OnClicked"></common:MainLabelNavigation>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ListView
x:Name="ListViewMensajes"
Grid.Row="1"
ItemsSource="{Binding Mensajes}"
SeparatorVisibility="None"
SeparatorColor="Transparent"
HasUnevenRows="True"
ItemTapped="OnItemTapped"
ItemTemplate="{StaticResource chatDataTemplateSelector}">
</ListView>
<!--- BUTTONS CONTAINER -->
<Grid
x:Name="ContainerSend"
Grid.Row="2"
ColumnSpacing="5"
Padding="0"
MinimumHeightRequest="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="55"/>
</Grid.RowDefinitions>
<app:GradientButton Grid.Row="0" Grid.Column="0"
Margin="0,0,0,0"
VerticalOptions="End"
HorizontalOptions="FillAndExpand"
Command="{Binding EnviarVideoCommand}"
ButtonType="Gray"
Text="Tomar Video"/>
<app:GradientButton Grid.Row="0" Grid.Column="1"
Margin="0,0,0,0"
VerticalOptions="End"
HorizontalOptions="FillAndExpand"
Command="{Binding EnviarImagenCommand}"
ButtonType="Gray"
Text="Tomar Foto"/>
<StackLayout Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
Margin="0,0,0,15"
BackgroundColor="{ DynamicResource TranslucidOrange }"
Orientation="Horizontal">
<!--- ENTRY -->
<Entry
HorizontalOptions="FillAndExpand"
FontSize="14"
Placeholder="Escribe tu mensaje..."
Text="{Binding Path=Mensaje, Mode=TwoWay}"/>
<!--- SEND BUTTON -->
<app:FontAwesomeIcon
x:Name="SendButton"
HorizontalOptions="End"
Margin="10,0"
Text="{ x:Static app:Icon.FAPlay }"
FontSize="20"
TextColor="{StaticResource BorderTextColor}"
Style="{ StaticResource FontIcon }"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"/>
</StackLayout>
</Grid>
<app:CustomActivityIndicator
IsVisible="{Binding IsLoading}"
Grid.Row="0" Grid.RowSpan="3"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"/>
</Grid>
</Grid>
</ContentPage>
我已经尝试过以各种方式更改视图,但是由于我是Xamarin开发应用程序的新手,所以我仍然不了解或不了解它们处理得很好。