title: Xamarin: Get the keyboard height Cross platform
body: <p>I wish to write a dependency service to get the keyboard height when the keyboard appears after tapping any entry cell. </p>
  
  <h2>Interface in PCL</h2>
  
  <pre><code>public interface IKeyboardService
      {
          int GetHeight();
      }
  </code></pre>
  
  <h2>Xaml code</h2>
  
  <pre><code> &lt;ContentPage.Content&gt; 
          &lt;Grid&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="*" /&gt;
                  &lt;RowDefinition Height="auto" /&gt;
              &lt;/Grid.RowDefinitions&gt;
  
              &lt;StackLayout Grid.Row="1"&gt;
                  &lt;Entry Text="Tap to open the keyboard" Focused="entryUserName_Focused" /&gt;
                  &lt;Button Text="Submit" Clicked="Handle_Clicked" /&gt;
              &lt;/StackLayout&gt;
          &lt;/Grid&gt;     
      &lt;/ContentPage.Content&gt;
  </code></pre>
  
  <h2>Behind code</h2>
  
  <pre><code>   private void entryUserName_Focused(object sender, FocusEventArgs e)
          {
              int height= DependencyService.Get&lt;IKeyboardService&gt;().GetHeight();
          }
  </code></pre>
  
  <h2>Overriding interface in Android</h2>
  
  <pre><code>   public class Keyboard_Droid : IKeyboardService
      {
        public int GetHeight()
          {
              // Logic to implement
              return h;
          }
      }
  </code></pre>
  
  <h2>Overriding interface in IOS</h2>
  
  <pre><code>public class Keyboard_IOS : IKeyboardService
          {
            public int GetHeight()
              {
                  // Logic to implement
                  return h;
              }
          }
  </code></pre>
  
  <p>Can anyone suggest the implementation to achieve this.</p>