summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorChong Zhang <chz@google.com>2016-06-02 20:58:05 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-06-02 20:58:06 +0000
commitb1e24209f16621fd095dacb615364bfd15dfe721 (patch)
treeccc498a7a86eccb22c4cff7b2757b4ca2f26d11c /core/java/android
parent453951d0777b1421e95bbcac501fb8b091c0f6a3 (diff)
parent67254723297442a7ac6a2479ec7f72f38f310c3c (diff)
Merge "Fix scroll amount calculation in ViewRootImpl" into nyc-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/ViewRootImpl.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 0d648c12d23c..4742818d4be0 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -3078,16 +3078,22 @@ public final class ViewRootImpl implements ViewParent,
// best is probably just to leave things as-is.
if (DEBUG_INPUT_RESIZE) Log.v(mTag,
"Too tall; leaving scrollY=" + scrollY);
- } else if ((mTempRect.top-scrollY) < vi.top) {
- scrollY -= vi.top - (mTempRect.top-scrollY);
+ }
+ // Next, check whether top or bottom is covered based on the non-scrolled
+ // position, and calculate new scrollY (or set it to 0).
+ // We can't keep using mScrollY here. For example mScrollY is non-zero
+ // due to IME, then IME goes away. The current value of mScrollY leaves top
+ // and bottom both visible, but we still need to scroll it back to 0.
+ else if (mTempRect.top < vi.top) {
+ scrollY = mTempRect.top - vi.top;
if (DEBUG_INPUT_RESIZE) Log.v(mTag,
"Top covered; scrollY=" + scrollY);
- } else if ((mTempRect.bottom-scrollY)
- > (mView.getHeight()-vi.bottom)) {
- scrollY += (mTempRect.bottom-scrollY)
- - (mView.getHeight()-vi.bottom);
+ } else if (mTempRect.bottom > (mView.getHeight()-vi.bottom)) {
+ scrollY = mTempRect.bottom - (mView.getHeight()-vi.bottom);
if (DEBUG_INPUT_RESIZE) Log.v(mTag,
"Bottom covered; scrollY=" + scrollY);
+ } else {
+ scrollY = 0;
}
handled = true;
}