C# Xamarin:跨平台获取键盘高度
我希望编写一个依赖项服务,以便在点击任何输入单元格后出现键盘时获得键盘高度 PCL中的接口 Xaml代码 IOS中的重写接口C# Xamarin:跨平台获取键盘高度,c#,xaml,xamarin.forms,C#,Xaml,Xamarin.forms,我希望编写一个依赖项服务,以便在点击任何输入单元格后出现键盘时获得键盘高度 PCL中的接口 Xaml代码 IOS中的重写接口 任何人都可以提出实现这一点的建议。看看:android中的rootView和IOS中的NSNotificationCenter怎么样。我应该如何从PCL传递这些值。 public interface IKeyboardService { int GetHeight(); } <ContentPage.Content>
任何人都可以提出实现这一点的建议。看看:android中的rootView和IOS中的NSNotificationCenter怎么样。我应该如何从PCL传递这些值。
public interface IKeyboardService
{
int GetHeight();
}
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<StackLayout Grid.Row="1">
<Entry Text="Tap to open the keyboard" Focused="entryUserName_Focused" />
<Button Text="Submit" Clicked="Handle_Clicked" />
</StackLayout>
</Grid>
</ContentPage.Content>
private void entryUserName_Focused(object sender, FocusEventArgs e)
{
int height= DependencyService.Get<IKeyboardService>().GetHeight();
}
public class Keyboard_Droid : IKeyboardService
{
public int GetHeight()
{
// Logic to implement
return h;
}
}
public class Keyboard_IOS : IKeyboardService
{
public int GetHeight()
{
// Logic to implement
return h;
}
}