Android examples for User Interface:View Center
get View Center as Point object
//package com.java2s; import android.graphics.Point; import android.view.View; public class Main { public static Point getViewCenter(View view) { if (view == null) { return new Point(); }// ww w.j av a2 s. com int[] location = new int[2]; view.getLocationOnScreen(location); int x = location[0] + view.getWidth() / 2; int y = location[1] + view.getHeight() / 2; return new Point(x, y); } }