get Display Center Pixel - Android Graphics

Android examples for Graphics:Pixel

Description

get Display Center Pixel

Demo Code


//package com.java2s;
import android.content.Context;
import android.graphics.Point;
import android.view.Display;
import android.view.WindowManager;

public class Main {
    public static int getDisplayCenterPixel(Context context) {
        WindowManager wm = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);//  w  w  w  . ja v  a  2s .  com
        return size.y / 2;
    }
}

Related Tutorials