get View Center Position - Android User Interface

Android examples for User Interface:View Center

Description

get View Center Position

Demo Code


//package com.java2s;

import android.view.View;

public class Main {
    public static float[] getViewCenterPosition(View v) {
        float x = v.getX() + v.getWidth() / 2;
        float y = v.getY() + v.getHeight() / 2;
        float[] ret = { x, y };
        return ret;
    }/*www.  j  av a 2s  . co m*/
}

Related Tutorials