Xaml 键盘上的焦点输入
我正在开发Xamarin.Forms PCL应用程序。我试图让它,让用户可以评论的文章显示后,滚动显示评论与停靠在页面底部的条目在任何时候 我试过了Xaml 键盘上的焦点输入,xaml,xamarin,xamarin.forms,xamarin.ios,Xaml,Xamarin,Xamarin.forms,Xamarin.ios,我正在开发Xamarin.Forms PCL应用程序。我试图让它,让用户可以评论的文章显示后,滚动显示评论与停靠在页面底部的条目在任何时候 我试过了 <ContentPage.Content> <StackLayout> <StackLayout> <ScrollView> <local:PostListView x:Name="Post">
<ContentPage.Content>
<StackLayout>
<StackLayout>
<ScrollView>
<local:PostListView x:Name="Post">
</local:PostListView>
<StackLayout>
<ListView x:Name="CommentsList">
</ListView>
</StackLayout>
</ScrollView>
</StackLayout>
<StackLayout Padding="10, 5, 10, 10">
<Entry Placeholder="Comment" BackgroundColor="GhostWhite"/>
<StackLayout Orientation="Horizontal">
<Button Text="Send" HeightRequest="20" HorizontalOptions="EndAndExpand" VerticalOptions="CenterAndExpand" Margin="0, 0, 5, 0"/>
</StackLayout>
</StackLayout>
</StackLayout>
</ContentPage.Content>
但是,当我单击键盘覆盖的条目时,是否可以使其位于键盘上方?对于Android,您应该设置:
Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
Xamarin.Forms.Application.Current.On().UseWindowsOfInputModeAdjust(WindowsOfInputModeAdjust.Resize);
对于iOS:
Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.iOS> ().UseWindowSoftInputModeAdjust (WindowSoftInputModeAdjust.Resize);
Xamarin.Forms.Application.Current.On().UseWindowsOfInputModeAdjust(WindowsOfInputModeAdjust.Resize);
您可以试试
它是如何工作的?
1.键盘显示/取消事件的子脚本
2.键盘秀
3.找到激活键盘的控件。(第一响应者)
4.确定键盘是否与控件重叠
5.计算你需要将页面向上移动多远
6.将页面向上移动
7.在键盘上
8.如果页面向上移动,则向下移动页面关于iOS?我会在有条目的页面中设置它,对于iOS和Android。否则,是否需要自定义渲染器?我无法确定在何处添加此代码?它是放在iOS和Android主页上,还是放在我需要它的页面的XAML中?@Dan Its C#,你必须把它放在共享项目中有条目的页面上。