I wish to write a dependency service to get the keyboard height when the keyboard appears after tapping any entry cell.
Interface in PCL
public interface IKeyboardService
{
int GetHeight();
}
Xaml code
<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>
Behind code
private void entryUserName_Focused(object sender, FocusEventArgs e)
{
int height= DependencyService.Get<IKeyboardService>().GetHeight();
}
Overriding interface in Android
public class Keyboard_Droid : IKeyboardService
{
public int GetHeight()
{
// Logic to implement
return h;
}
}
Overriding interface in IOS
public class Keyboard_IOS : IKeyboardService
{
public int GetHeight()
{
// Logic to implement
return h;
}
}
Can anyone suggest the implementation to achieve this.