Add get center position in ancestor

This commit is contained in:
seven332 committed 2015-05-12 01:04:17 +08:00
1 parent 8f7fafcf7d
commit 965d5c0ef5
1 file changed
+12
@@ -49,6 +49,12 @@ public final class ViewUtils {
getLocationInAncestor(view, location, android.R.id.content);
}
public static void getCenterInAncestor(View view, int[] location, int ancestorId) {
getLocationInAncestor(view, location, ancestorId);
location[0] += view.getWidth() / 2;
location[1] += view.getHeight() / 2;
}
/**
* Get view location in ths ancestor
*
@@ -87,6 +93,12 @@ public final class ViewUtils {
location[1] = (int) (position[1] + 0.5f);
}
public static void getCenterInAncestor(View view, int[] location, View ancestor) {
getLocationInAncestor(view, location, ancestor);
location[0] += view.getWidth() / 2;
location[1] += view.getHeight() / 2;
}
/**
* Get view location in ths ancestor
*