Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.PointF;
import android.view.View;

public class Main {
    /**
     * Get center locations delta between two views.
     *
     * @param viewA View A.
     * @param viewB View B.
     * @return Locations delta as a point.
     */
    private static PointF getCenterLocationsDelta(final View viewA, final View viewB) {
        final int[] fromLocation = new int[2];
        viewA.getLocationOnScreen(fromLocation);
        final int[] toLocation = new int[2];
        viewB.getLocationOnScreen(toLocation);
        final int deltaX = toLocation[0] - fromLocation[0] + viewB.getMeasuredWidth() / 2
                - viewA.getMeasuredWidth() / 2;
        final int deltaY = toLocation[1] - fromLocation[1] + viewB.getMeasuredHeight() / 2
                - viewA.getMeasuredHeight() / 2;
        return new PointF(deltaX, deltaY);
    }
}