diff --git a/java/res/values-hdpi/keyboard_key_feedback_background_holo.xml b/java/res/values-hdpi/keyboard_key_feedback_background_holo.xml
new file mode 100644
index 0000000000000000000000000000000000000000..8ab32269d28ccca0414a82d68ae7c8d91afe3d19
--- /dev/null
+++ b/java/res/values-hdpi/keyboard_key_feedback_background_holo.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources>
+    <dimen name="keyboard_key_feedback_background_holo_width">46.67dp</dimen>
+    <dimen name="keyboard_key_feedback_background_holo_height">58.67dp</dimen>
+</resources>
diff --git a/java/res/values-mdpi/keyboard_key_feedback_background_holo.xml b/java/res/values-mdpi/keyboard_key_feedback_background_holo.xml
new file mode 100644
index 0000000000000000000000000000000000000000..10fef3d4809f038cd2a11f0e8f372d0c02454860
--- /dev/null
+++ b/java/res/values-mdpi/keyboard_key_feedback_background_holo.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources>
+    <dimen name="keyboard_key_feedback_background_holo_width">46dp</dimen>
+    <dimen name="keyboard_key_feedback_background_holo_height">58dp</dimen>
+</resources>
diff --git a/java/res/values-xhdpi/keyboard_key_feedback_background_holo.xml b/java/res/values-xhdpi/keyboard_key_feedback_background_holo.xml
new file mode 100644
index 0000000000000000000000000000000000000000..fba602626ddf9fb5aaaecfba458d66d373bc9339
--- /dev/null
+++ b/java/res/values-xhdpi/keyboard_key_feedback_background_holo.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources>
+    <dimen name="keyboard_key_feedback_background_holo_width">47dp</dimen>
+    <dimen name="keyboard_key_feedback_background_holo_height">57dp</dimen>
+</resources>
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 4dfa5ab975c239a536517a1286d48b9226cf7376..e569e83b1d14a78ac50bd7fe93d1dcca39a91d99 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -88,6 +88,10 @@
         <attr name="keyPreviewLeftBackground" format="reference" />
         <!-- The background for the right edge key press feedback. -->
         <attr name="keyPreviewRightBackground" format="reference" />
+        <!-- The width of rectangle part of the key press feedback background. -->
+        <attr name="keyPreviewBackgroundWidth" format="dimension" />
+        <!-- The height of rectangle part of the key press feedback background. -->
+        <attr name="keyPreviewBackgroundHeight" format="dimension" />
         <!-- The text color for key press feedback. -->
         <attr name="keyPreviewTextColor" format="color" />
         <!-- Vertical offset of the key press feedback from the key. -->
diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml
index 30c0e5a3832f5e28e8074425f1418e520a8dde4e..43aa58388f63a56d681a2bcf70c19bc25c36e993 100644
--- a/java/res/values/styles.xml
+++ b/java/res/values/styles.xml
@@ -259,6 +259,8 @@
         <item name="keyPreviewBackground">@drawable/keyboard_key_feedback_ics</item>
         <item name="keyPreviewLeftBackground">@drawable/keyboard_key_feedback_left_ics</item>
         <item name="keyPreviewRightBackground">@drawable/keyboard_key_feedback_right_ics</item>
+        <item name="keyPreviewBackgroundWidth">@dimen/keyboard_key_feedback_background_holo_width</item>
+        <item name="keyPreviewBackgroundHeight">@dimen/keyboard_key_feedback_background_holo_height</item>
         <item name="keyPreviewTextColor">#FFFFFFFF</item>
         <item name="keyPreviewHeight">@dimen/key_preview_height_ics</item>
         <item name="keyPreviewOffset">@dimen/key_preview_offset_ics</item>
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index e69dc581b09b6336bd0c174d8c3aa1ec74437080..04e6725908cd524c1bcc9c05c75051a949afddd1 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -100,7 +100,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
 
     // Key preview
     private final int mKeyPreviewLayoutId;
-    private final KeyPreviewDrawParams mKeyPreviewDrawParams;
+    protected final KeyPreviewDrawParams mKeyPreviewDrawParams;
     private boolean mShowKeyPreviewPopup = true;
     private final int mDelayBeforePreview;
     private int mDelayAfterPreview;
@@ -284,11 +284,13 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
         }
     }
 
-    private static class KeyPreviewDrawParams {
+    protected static class KeyPreviewDrawParams {
         // XML attributes.
         public final Drawable mPreviewBackground;
         public final Drawable mPreviewLeftBackground;
         public final Drawable mPreviewRightBackground;
+        public final int mPreviewBackgroundWidth;
+        public final int mPreviewBackgroundHeight;
         public final int mPreviewTextColor;
         public final int mPreviewOffset;
         public final int mPreviewHeight;
@@ -312,6 +314,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
             setAlpha(mPreviewBackground, PREVIEW_ALPHA);
             setAlpha(mPreviewLeftBackground, PREVIEW_ALPHA);
             setAlpha(mPreviewRightBackground, PREVIEW_ALPHA);
+            mPreviewBackgroundWidth = a.getDimensionPixelSize(
+                    R.styleable.KeyboardView_keyPreviewBackgroundWidth, 0);
+            mPreviewBackgroundHeight = a.getDimensionPixelSize(
+                    R.styleable.KeyboardView_keyPreviewBackgroundHeight, 0);
             mPreviewOffset = a.getDimensionPixelOffset(
                     R.styleable.KeyboardView_keyPreviewOffset, 0);
             mPreviewHeight = a.getDimensionPixelSize(
diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
index d4b35a5562183508247779760870e6c6e236306e..ac9290bfd33153b1572615ad197dd3d7d07fb528 100644
--- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
@@ -215,10 +215,21 @@ public class MiniKeyboard extends Keyboard {
             mParams.mIsRtlKeyboard = parentKeyboard.mIsRtlKeyboard;
             mMoreKeys = parentKey.mMoreKeys;
 
-            final int keyWidth = getMaxKeyWidth(view, mMoreKeys, mParams.mDefaultKeyWidth);
-            mParams.setParameters(mMoreKeys.length, parentKey.mMaxMoreKeysColumn,
-                    keyWidth, parentKeyboard.mMostCommonKeyHeight, parentKey.mX
-                            + (mParams.mDefaultKeyWidth - keyWidth) / 2, view.getMeasuredWidth());
+            final int previewWidth = view.mKeyPreviewDrawParams.mPreviewBackgroundWidth;
+            final int previewHeight = view.mKeyPreviewDrawParams.mPreviewBackgroundHeight;
+            final int width, height;
+            // Use pre-computed width and height if these values are available and mini keyboard
+            // has only one key to mitigate visual flicker between key preview and mini keyboard.
+            if (view.isKeyPreviewPopupEnabled() && mMoreKeys.length == 1 && previewWidth > 0
+                    && previewHeight > 0) {
+                width = previewWidth;
+                height = previewHeight + mParams.mVerticalGap;
+            } else {
+                width = getMaxKeyWidth(view, parentKey.mMoreKeys, mParams.mDefaultKeyWidth);
+                height = parentKeyboard.mMostCommonKeyHeight;
+            }
+            mParams.setParameters(mMoreKeys.length, parentKey.mMaxMoreKeysColumn, width, height,
+                    parentKey.mX + (mParams.mDefaultKeyWidth - width) / 2, view.getMeasuredWidth());
         }
 
         private static int getMaxKeyWidth(KeyboardView view, CharSequence[] moreKeys,