diff --git a/build.gradle b/build.gradle index f31aef9..72b6f1f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:2.3.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6' } diff --git a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java index 29f0f34..57f48c5 100755 --- a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java +++ b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java @@ -437,23 +437,18 @@ public void run() { targetBounds.set(target.bounds()); - getLocationOnScreen(offset); + getLocationInWindow(offset); targetBounds.offset(-offset[0], -offset[1]); if (boundingParent != null) { - final WindowManager windowManager - = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); - final DisplayMetrics displayMetrics = new DisplayMetrics(); - windowManager.getDefaultDisplay().getMetrics(displayMetrics); - - final Rect rect = new Rect(); - boundingParent.getWindowVisibleDisplayFrame(rect); + int[] viewLocation = new int[2]; + boundingParent.getLocationInWindow(viewLocation); // We bound the boundaries to be within the screen's coordinates to // handle the case where the layout bounds do not match // (like when FLAG_LAYOUT_NO_LIMITS is specified) - topBoundary = Math.max(0, rect.top); - bottomBoundary = Math.min(rect.bottom, displayMetrics.heightPixels); + topBoundary = Math.max(0, viewLocation[1]); + bottomBoundary = viewLocation[1] + boundingParent.getHeight(); } drawTintedTarget(); diff --git a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/ViewTapTarget.java b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/ViewTapTarget.java index c6f42d4..580f77d 100755 --- a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/ViewTapTarget.java +++ b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/ViewTapTarget.java @@ -40,7 +40,7 @@ public void onReady(final Runnable runnable) { public void run() { // Cache bounds final int[] location = new int[2]; - view.getLocationOnScreen(location); + view.getLocationInWindow(location); bounds = new Rect(location[0], location[1], location[0] + view.getWidth(), location[1] + view.getHeight());