Android examples for User Interface:Screen Position
get Center X Screen Position
//package com.java2s; import android.content.Context; import android.graphics.Point; import android.view.Display; import android.view.WindowManager; public class Main { public static float getCenterXScreenPosition(Context context) { Point p = getCenterScreenPosition(context); return p.x; }/* ww w . ja v a2s. c om*/ public static Point getCenterScreenPosition(Context context) { Point p = getScreenSize(context); p.x = p.x / 2; p.y = p.y / 2; return p; } public static Point getScreenSize(Context context) { Display display = ((WindowManager) context .getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size; } }