Fix more keys keyboard display position

This is a follow up of Ia39b3d6de8.

Change-Id: I9e6152fdc5cb9fa9490b41fcf0420b9ffccea438
main
Tadashi G. Takaoka 2013-11-20 13:07:26 +09:00
parent 077b3def52
commit 0381415423
2 changed files with 6 additions and 4 deletions

View File

@ -223,7 +223,7 @@ public final class MoreKeysKeyboard extends Keyboard {
} }
public int getDefaultKeyCoordX() { public int getDefaultKeyCoordX() {
return mLeftKeys * mColumnWidth; return mLeftKeys * mColumnWidth + mLeftPadding;
} }
public int getX(final int n, final int row) { public int getX(final int n, final int row) {

View File

@ -81,11 +81,13 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
mListener = listener; mListener = listener;
final View container = getContainerView(); final View container = getContainerView();
// The coordinates of panel's left-top corner in parentView's coordinate system. // The coordinates of panel's left-top corner in parentView's coordinate system.
final int x = pointX - getDefaultCoordX() - container.getPaddingLeft(); // We need to consider background drawable paddings.
final int y = pointY - container.getMeasuredHeight() + container.getPaddingBottom(); final int x = pointX - getDefaultCoordX() - container.getPaddingLeft() - getPaddingLeft();
final int y = pointY - container.getMeasuredHeight() + container.getPaddingBottom()
+ getPaddingBottom();
parentView.getLocationInWindow(mCoordinates); parentView.getLocationInWindow(mCoordinates);
// Ensure the horizontal position of the panel does not extend past the screen edges. // Ensure the horizontal position of the panel does not extend past the parentView edges.
final int maxX = parentView.getMeasuredWidth() - container.getMeasuredWidth(); final int maxX = parentView.getMeasuredWidth() - container.getMeasuredWidth();
final int panelX = Math.max(0, Math.min(maxX, x)) + CoordinateUtils.x(mCoordinates); final int panelX = Math.max(0, Math.min(maxX, x)) + CoordinateUtils.x(mCoordinates);
final int panelY = y + CoordinateUtils.y(mCoordinates); final int panelY = y + CoordinateUtils.y(mCoordinates);