WebViewClassic.java では、実際の縮尺がデフォルトの縮尺よりも小さい場合、 displaySoftKeyboardはズームインおよびパンします。WebWiew.class mDefaultScale float にはフィールドがあり、ソース コードは、ソフトキーボードを表示すると mAActualScale が変化することを示しています。
したがって、mActualScale が >= mDefaultScale であることを確認すると、パンと再スケーリングを防ぐことができます。(以下は、grepcode サイトからの WebView.java のソース コードです。このサイトはもう実行されていません。)
private void displaySoftKeyboard(boolean isTextView) {
InputMethodManager imm = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (isTextView) {
if (mWebTextView == null) return;
imm.showSoftInput(mWebTextView, 0);
if (mActualScale < mDefaultScale) {
// bring it back to the default scale so that user can enter
// text.
mInZoomOverview = false;
mZoomCenterX = mLastTouchX;
mZoomCenterY = mLastTouchY;
// do not change text wrap scale so that there is no reflow
setNewZoomScale(mDefaultScale, false, false);
adjustTextView(false);
}
}
else { // used by plugins
imm.showSoftInput(this, 0);
}
}
googleSourceのコード- Frameworks/base/core/java/android/webkit/WebViewClassic.java の WebViewClassic.java (JellyBean api 17 用) は、同様の機能を示しています。
/**
* Called in response to a message from webkit telling us that the soft
* keyboard should be launched.
*/
private void displaySoftKeyboard(boolean isTextView) {
InputMethodManager imm = (InputMethodManager)
mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
// bring it back to the default level scale so that user can enter text
boolean zoom = mZoomManager.getScale() < mZoomManager.getDefaultScale();
if (zoom) {
mZoomManager.setZoomCenter(mLastTouchX, mLastTouchY);
mZoomManager.setZoomScale(mZoomManager.getDefaultScale(), false);
}
// Used by plugins and contentEditable.
// Also used if the navigation cache is out of date, and
// does not recognize that a textfield is in focus. In that
// case, use WebView as the targeted view.
// see http://b/issue?id=2457459
imm.showSoftInput(mWebView, 0);
}