Code example for View

Methods: getHeight, getLocationOnScreen

0
    static public void assertOnBottomEdgeOfScreen(View origin, View view) {
        int[] xy = new int[2];
        view.getLocationOnScreen(xy);
 
        int[] xyRoot = new int[2];
        origin.getLocationOnScreen(xyRoot);
 
        int bottom = xy[1] + view.getHeight();
        int bottomOfRoot = xyRoot[1] + origin.getHeight();
 
        assertTrue(bottom > bottomOfRoot);
 
        assertTrue(xy[1] < bottomOfRoot);
        assertTrue(bottom > bottomOfRoot);
    } 
 
    /** 
     * Assert that view overlaps the bottom edge of the screen 
     * @param origin The root view of the screen. 
     * @param view The view 
     */