Specify keyboard metrics with physical unit "inch" (DO NOT MERGE)

This change also introduces the key background drawables which has no
fixed bottom padding.  Instead of relying on bottom padding in
drawable, this change also specifies Keyboard.verticalGap with
physical unit.  Other keyboard related length, distance and size are
also specified by physical unit.

Bug: 3066107

Change-Id: I44f3b2eef8086d6e0b0db53d38f08487549060c6
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal.9.png
index 0c4820b..01fc8ca 100644
--- a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal.9.png
+++ b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal.9.png
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_off.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_off.9.png
index 5a20da1..af4017e 100644
--- a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_off.9.png
+++ b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_off.9.png
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_on.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_on.9.png
index 4ec703d..4c35aca 100644
--- a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_on.9.png
+++ b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_on.9.png
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed.9.png
index 93322d2..174f345 100644
--- a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed.9.png
+++ b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed.9.png
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_off.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_off.9.png
index 5a9c722..1fcbd9a 100644
--- a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_off.9.png
+++ b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_off.9.png
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_on.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_on.9.png
index 99b6cb1..072753f 100644
--- a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_on.9.png
+++ b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_on.9.png
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_light_normal.9.png b/java/res/drawable-hdpi/btn_keyboard_key_light_normal.9.png
index 7dc59bf..1ad7460 100644
--- a/java/res/drawable-hdpi/btn_keyboard_key_light_normal.9.png
+++ b/java/res/drawable-hdpi/btn_keyboard_key_light_normal.9.png
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_light_pressed.9.png b/java/res/drawable-hdpi/btn_keyboard_key_light_pressed.9.png
index c150341..ccd59d5 100644
--- a/java/res/drawable-hdpi/btn_keyboard_key_light_pressed.9.png
+++ b/java/res/drawable-hdpi/btn_keyboard_key_light_pressed.9.png
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal.9.png
index 53fe9c9..4e337fa 100644
--- a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal.9.png
+++ b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal.9.png
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_off.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_off.9.png
index 649ef97..fe18497 100644
--- a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_off.9.png
+++ b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_off.9.png
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_on.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_on.9.png
index 93f7d87..00aab3d 100644
--- a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_on.9.png
+++ b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_on.9.png
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed.9.png
index 8560b3b..ac0bfd3 100644
--- a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed.9.png
+++ b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed.9.png
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_off.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_off.9.png
index 778abaf..ea2f357 100644
--- a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_off.9.png
+++ b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_off.9.png
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_on.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_on.9.png
index 2a23945..6195ac0 100644
--- a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_on.9.png
+++ b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_on.9.png
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_light_normal.9.png b/java/res/drawable-mdpi/btn_keyboard_key_light_normal.9.png
index 6af2d8d..50cd06a 100644
--- a/java/res/drawable-mdpi/btn_keyboard_key_light_normal.9.png
+++ b/java/res/drawable-mdpi/btn_keyboard_key_light_normal.9.png
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_light_pressed.9.png b/java/res/drawable-mdpi/btn_keyboard_key_light_pressed.9.png
index fdaf699..7ce52f0 100644
--- a/java/res/drawable-mdpi/btn_keyboard_key_light_pressed.9.png
+++ b/java/res/drawable-mdpi/btn_keyboard_key_light_pressed.9.png
Binary files differ
diff --git a/java/res/layout/input_gingerbread.xml b/java/res/layout/input_gingerbread.xml
index 8f59cae..73cf0a3 100644
--- a/java/res/layout/input_gingerbread.xml
+++ b/java/res/layout/input_gingerbread.xml
@@ -25,6 +25,7 @@
         android:layout_alignParentBottom="true"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:paddingBottom="@dimen/keyboard_bottom_padding"
         android:background="@drawable/keyboard_dark_background"
         android:textStyle="bold"
 
diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml
index 1396bff..043f4b3 100644
--- a/java/res/values-land/dimens.xml
+++ b/java/res/values-land/dimens.xml
@@ -19,13 +19,17 @@
 -->
 
 <resources>
-    <dimen name="key_height">47dip</dimen>
+    <!-- key_height + key_bottom_gap = popup_key_height -->
+    <dimen name="key_height">0.250in</dimen>
+    <dimen name="key_bottom_gap">0.020in</dimen>
+    <dimen name="popup_key_height">0.270in</dimen>
+    <dimen name="keyboard_bottom_padding">0.0in</dimen>
     <dimen name="candidate_strip_height">38dip</dimen>
     <dimen name="candidate_strip_fading_edge_length">63dip</dimen>
     <dimen name="spacebar_vertical_correction">2dip</dimen>
     <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
-    <!-- key_height x 1.7 -->
-    <dimen name="mini_keyboard_slide_allowance">79.9dip</dimen>
-    <!-- -key_height x 1.0 -->
-    <dimen name="mini_keyboard_vertical_correction">-47dip</dimen>
+    <!-- popup_key_height x 1.7 -->
+    <dimen name="mini_keyboard_slide_allowance">0.459in</dimen>
+    <!-- popup_key_height x 1.0 -->
+    <dimen name="mini_keyboard_vertical_correction">-0.270in</dimen>
 </resources>
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index 1378be7..c00c56a 100644
--- a/java/res/values/dimens.xml
+++ b/java/res/values/dimens.xml
@@ -19,7 +19,11 @@
 -->
 
 <resources>
-    <dimen name="key_height">54dip</dimen>
+    <!-- key_height + key_bottom_gap = popup_key_height -->
+    <dimen name="key_height">0.290in</dimen>
+    <dimen name="key_bottom_gap">0.035in</dimen>
+    <dimen name="popup_key_height">0.325in</dimen>
+    <dimen name="keyboard_bottom_padding">0.06in</dimen>
     <dimen name="bubble_pointer_offset">22dip</dimen>
     <dimen name="candidate_strip_height">42dip</dimen>
     <dimen name="candidate_strip_fading_edge_length">63dip</dimen>
@@ -27,18 +31,20 @@
     <!-- If the screen height in landscape is larger than the below value, then the keyboard
          will not go into extract (fullscreen) mode. -->
     <dimen name="max_height_for_fullscreen">2.5in</dimen>
-    <dimen name="key_text_size">22sp</dimen>
-    <dimen name="key_label_text_size">14sp</dimen>
-    <dimen name="key_preview_offset">0dip</dimen>
-    <dimen name="key_preview_height">80dip</dimen>
+    <dimen name="key_text_size">0.13in</dimen>
+    <dimen name="key_label_text_size">0.083in</dimen>
+    <dimen name="key_preview_text_size_large">0.236in</dimen>
+    <dimen name="key_preview_offset">0.000in</dimen>
+    <!-- key_height x 1.6 -->
+    <dimen name="key_preview_height">0.464in</dimen>
     <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
-    <!-- key_height x 1.7 -->
-    <dimen name="mini_keyboard_slide_allowance">91.8dip</dimen>
-    <!-- -key_height x 1.0 -->
-    <dimen name="mini_keyboard_vertical_correction">-54dip</dimen>
+    <!-- popup_key_height x 1.7 -->
+    <dimen name="mini_keyboard_slide_allowance">0.553in</dimen>
+    <!-- popup_key_height x 1.0 -->
+    <dimen name="mini_keyboard_vertical_correction">-0.325in</dimen>
     <dimen name="key_hysteresis_distance">0.05in</dimen>
     <!-- We use "inch", not "dip" because this value tries dealing with physical distance related
          to user's finger. -->
-    <dimen name="keyboard_vertical_correction">-0.06in</dimen>
+    <dimen name="keyboard_vertical_correction">-0.05in</dimen>
     <dimen name="candidate_min_touchable_width">0.3in</dimen>
 </resources>
diff --git a/java/res/xml-da/kbd_qwerty.xml b/java/res/xml-da/kbd_qwerty.xml
index 0847954..6e2e692 100644
--- a/java/res/xml-da/kbd_qwerty.xml
+++ b/java/res/xml-da/kbd_qwerty.xml
@@ -28,10 +28,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="9.09%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="q"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-da/kbd_qwerty_black.xml b/java/res/xml-da/kbd_qwerty_black.xml
index 9a64e86..36656ed 100644
--- a/java/res/xml-da/kbd_qwerty_black.xml
+++ b/java/res/xml-da/kbd_qwerty_black.xml
@@ -28,10 +28,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="9.09%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="q"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-de/kbd_qwerty.xml b/java/res/xml-de/kbd_qwerty.xml
index b60c50d..e74f137 100644
--- a/java/res/xml-de/kbd_qwerty.xml
+++ b/java/res/xml-de/kbd_qwerty.xml
@@ -22,10 +22,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="q"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-de/kbd_qwerty_black.xml b/java/res/xml-de/kbd_qwerty_black.xml
index 5cca5a6..2c0d6d5 100644
--- a/java/res/xml-de/kbd_qwerty_black.xml
+++ b/java/res/xml-de/kbd_qwerty_black.xml
@@ -22,10 +22,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="q"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-fr/kbd_qwerty.xml b/java/res/xml-fr/kbd_qwerty.xml
index ab78b37..bded3e3 100644
--- a/java/res/xml-fr/kbd_qwerty.xml
+++ b/java/res/xml-fr/kbd_qwerty.xml
@@ -22,10 +22,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="a"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-fr/kbd_qwerty_black.xml b/java/res/xml-fr/kbd_qwerty_black.xml
index 97b55dc..679d940 100644
--- a/java/res/xml-fr/kbd_qwerty_black.xml
+++ b/java/res/xml-fr/kbd_qwerty_black.xml
@@ -22,10 +22,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="a"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-iw/kbd_qwerty.xml b/java/res/xml-iw/kbd_qwerty.xml
index a48c849..0ad2ca3 100644
--- a/java/res/xml-iw/kbd_qwerty.xml
+++ b/java/res/xml-iw/kbd_qwerty.xml
@@ -22,10 +22,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="ק"
             android:horizontalGap="5%p"
diff --git a/java/res/xml-iw/kbd_qwerty_black.xml b/java/res/xml-iw/kbd_qwerty_black.xml
index a72b036..10ca0fc 100644
--- a/java/res/xml-iw/kbd_qwerty_black.xml
+++ b/java/res/xml-iw/kbd_qwerty_black.xml
@@ -22,10 +22,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="ק"
             android:horizontalGap="5%p"
diff --git a/java/res/xml-nb/kbd_qwerty.xml b/java/res/xml-nb/kbd_qwerty.xml
index 7e16106..8377bbf 100644
--- a/java/res/xml-nb/kbd_qwerty.xml
+++ b/java/res/xml-nb/kbd_qwerty.xml
@@ -28,10 +28,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="9.09%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="q"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-nb/kbd_qwerty_black.xml b/java/res/xml-nb/kbd_qwerty_black.xml
index f6a034e..ab14984 100644
--- a/java/res/xml-nb/kbd_qwerty_black.xml
+++ b/java/res/xml-nb/kbd_qwerty_black.xml
@@ -28,10 +28,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="9.09%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="q"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-ru/kbd_qwerty.xml b/java/res/xml-ru/kbd_qwerty.xml
index 9f16b9b..d40ccef 100644
--- a/java/res/xml-ru/kbd_qwerty.xml
+++ b/java/res/xml-ru/kbd_qwerty.xml
@@ -22,10 +22,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="9.09%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="й"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-ru/kbd_qwerty_black.xml b/java/res/xml-ru/kbd_qwerty_black.xml
index 73008be..cc71b08 100644
--- a/java/res/xml-ru/kbd_qwerty_black.xml
+++ b/java/res/xml-ru/kbd_qwerty_black.xml
@@ -22,10 +22,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="9.09%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="й"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-sr/kbd_qwerty.xml b/java/res/xml-sr/kbd_qwerty.xml
index c671166..835f8c1 100644
--- a/java/res/xml-sr/kbd_qwerty.xml
+++ b/java/res/xml-sr/kbd_qwerty.xml
@@ -23,10 +23,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="9.09%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="љ"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-sr/kbd_qwerty_black.xml b/java/res/xml-sr/kbd_qwerty_black.xml
index 5e5bcee..76a9e55 100644
--- a/java/res/xml-sr/kbd_qwerty_black.xml
+++ b/java/res/xml-sr/kbd_qwerty_black.xml
@@ -23,10 +23,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="9.09%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="љ"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-sv/kbd_qwerty.xml b/java/res/xml-sv/kbd_qwerty.xml
index 44117fc..f88bd3c 100644
--- a/java/res/xml-sv/kbd_qwerty.xml
+++ b/java/res/xml-sv/kbd_qwerty.xml
@@ -30,10 +30,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="9.09%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="q"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml-sv/kbd_qwerty_black.xml b/java/res/xml-sv/kbd_qwerty_black.xml
index 13ed3d1..8493237 100644
--- a/java/res/xml-sv/kbd_qwerty_black.xml
+++ b/java/res/xml-sv/kbd_qwerty_black.xml
@@ -30,10 +30,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="9.09%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="q"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml/kbd_phone.xml b/java/res/xml/kbd_phone.xml
index 0a01fa0..10774c6 100644
--- a/java/res/xml/kbd_phone.xml
+++ b/java/res/xml/kbd_phone.xml
@@ -22,7 +22,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="26.67%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
     <Row
diff --git a/java/res/xml/kbd_phone_black.xml b/java/res/xml/kbd_phone_black.xml
index 7a956b7..5afa9a1 100644
--- a/java/res/xml/kbd_phone_black.xml
+++ b/java/res/xml/kbd_phone_black.xml
@@ -22,7 +22,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="26.67%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
     <Row
diff --git a/java/res/xml/kbd_phone_symbols.xml b/java/res/xml/kbd_phone_symbols.xml
index 2dc93c1..4c928a8 100644
--- a/java/res/xml/kbd_phone_symbols.xml
+++ b/java/res/xml/kbd_phone_symbols.xml
@@ -22,7 +22,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="26.67%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
     <Row
diff --git a/java/res/xml/kbd_phone_symbols_black.xml b/java/res/xml/kbd_phone_symbols_black.xml
index 5bc6289..4d686e1 100644
--- a/java/res/xml/kbd_phone_symbols_black.xml
+++ b/java/res/xml/kbd_phone_symbols_black.xml
@@ -22,7 +22,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="26.67%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
     <Row
diff --git a/java/res/xml/kbd_popup_narrow_template.xml b/java/res/xml/kbd_popup_narrow_template.xml
index ed3b130..23c686e 100644
--- a/java/res/xml/kbd_popup_narrow_template.xml
+++ b/java/res/xml/kbd_popup_narrow_template.xml
@@ -22,6 +22,6 @@
     android:keyWidth="9.45%p"
     android:horizontalGap="0px"
     android:verticalGap="0px"
-    android:keyHeight="@dimen/key_height"
+    android:keyHeight="@dimen/popup_key_height"
     >
 </Keyboard>
diff --git a/java/res/xml/kbd_popup_template.xml b/java/res/xml/kbd_popup_template.xml
index aca4693..a287be1 100644
--- a/java/res/xml/kbd_popup_template.xml
+++ b/java/res/xml/kbd_popup_template.xml
@@ -22,6 +22,6 @@
     android:keyWidth="10%p"
     android:horizontalGap="0px"
     android:verticalGap="0px"
-    android:keyHeight="@dimen/key_height"
+    android:keyHeight="@dimen/popup_key_height"
     >
 </Keyboard>
diff --git a/java/res/xml/kbd_qwerty.xml b/java/res/xml/kbd_qwerty.xml
index c6113ab..a2c9b2b 100644
--- a/java/res/xml/kbd_qwerty.xml
+++ b/java/res/xml/kbd_qwerty.xml
@@ -22,10 +22,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="q"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml/kbd_qwerty_black.xml b/java/res/xml/kbd_qwerty_black.xml
index 33cec94..d9943a9 100644
--- a/java/res/xml/kbd_qwerty_black.xml
+++ b/java/res/xml/kbd_qwerty_black.xml
@@ -22,10 +22,12 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
-    <Row>
+    <Row
+        android:rowEdgeFlags="top"
+    >
         <Key
             android:keyLabel="q"
             android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/java/res/xml/kbd_symbols.xml b/java/res/xml/kbd_symbols.xml
index cb8b3b3..dfc5bd0 100644
--- a/java/res/xml/kbd_symbols.xml
+++ b/java/res/xml/kbd_symbols.xml
@@ -22,7 +22,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
     <Row
diff --git a/java/res/xml/kbd_symbols_black.xml b/java/res/xml/kbd_symbols_black.xml
index bfb1646..add7f9f 100644
--- a/java/res/xml/kbd_symbols_black.xml
+++ b/java/res/xml/kbd_symbols_black.xml
@@ -22,7 +22,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
     <Row
diff --git a/java/res/xml/kbd_symbols_shift.xml b/java/res/xml/kbd_symbols_shift.xml
index 21cbb71..9bee220 100644
--- a/java/res/xml/kbd_symbols_shift.xml
+++ b/java/res/xml/kbd_symbols_shift.xml
@@ -22,7 +22,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
     <Row
diff --git a/java/res/xml/kbd_symbols_shift_black.xml b/java/res/xml/kbd_symbols_shift_black.xml
index d5d49ce..52b67c3 100644
--- a/java/res/xml/kbd_symbols_shift_black.xml
+++ b/java/res/xml/kbd_symbols_shift_black.xml
@@ -22,7 +22,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:keyWidth="10%p"
     android:horizontalGap="0px"
-    android:verticalGap="0px"
+    android:verticalGap="@dimen/key_bottom_gap"
     android:keyHeight="@dimen/key_height"
 >
     <Row
diff --git a/java/res/xml/popup_comma.xml b/java/res/xml/popup_comma.xml
index 540dc96..7666f4b 100644
--- a/java/res/xml/popup_comma.xml
+++ b/java/res/xml/popup_comma.xml
@@ -23,7 +23,7 @@
     android:keyWidth="10%p"
     android:horizontalGap="0px"
     android:verticalGap="0px"
-    android:keyHeight="@dimen/key_height"
+    android:keyHeight="@dimen/popup_key_height"
 >
     <Row
         android:rowEdgeFlags="top|bottom"
diff --git a/java/res/xml/popup_domains.xml b/java/res/xml/popup_domains.xml
index 0f7d976..4e9789f 100644
--- a/java/res/xml/popup_domains.xml
+++ b/java/res/xml/popup_domains.xml
@@ -23,7 +23,7 @@
     android:keyWidth="15%p"
     android:horizontalGap="0px"
     android:verticalGap="0px"
-    android:keyHeight="@dimen/key_height"
+    android:keyHeight="@dimen/popup_key_height"
 >
     <Row
         android:rowEdgeFlags="top|bottom"
diff --git a/java/res/xml/popup_mic.xml b/java/res/xml/popup_mic.xml
index f3cc638..5bbd7df 100644
--- a/java/res/xml/popup_mic.xml
+++ b/java/res/xml/popup_mic.xml
@@ -23,7 +23,7 @@
     android:keyWidth="10%p"
     android:horizontalGap="0px"
     android:verticalGap="0px"
-    android:keyHeight="@dimen/key_height"
+    android:keyHeight="@dimen/popup_key_height"
 >
     <Row
         android:rowEdgeFlags="top|bottom"
diff --git a/java/res/xml/popup_punctuation.xml b/java/res/xml/popup_punctuation.xml
index ee1feab..c429e38 100644
--- a/java/res/xml/popup_punctuation.xml
+++ b/java/res/xml/popup_punctuation.xml
@@ -23,7 +23,7 @@
     android:keyWidth="10%p"
     android:horizontalGap="0px"
     android:verticalGap="0px"
-    android:keyHeight="@dimen/key_height"
+    android:keyHeight="@dimen/popup_key_height"
 >
     <Row
         android:rowEdgeFlags="top"
diff --git a/java/res/xml/popup_smileys.xml b/java/res/xml/popup_smileys.xml
index 3b556da..1a14e1d 100644
--- a/java/res/xml/popup_smileys.xml
+++ b/java/res/xml/popup_smileys.xml
@@ -23,7 +23,7 @@
     android:keyWidth="15%p"
     android:horizontalGap="0px"
     android:verticalGap="0px"
-    android:keyHeight="@dimen/key_height"
+    android:keyHeight="@dimen/popup_key_height"
 >
     <Row
         android:rowEdgeFlags="top"