get Rect Center Y - Android Graphics

Android examples for Graphics:Rectangle

Description

get Rect Center Y

Demo Code


//package com.java2s;
import android.graphics.Rect;
import android.graphics.RectF;

public class Main {
    public static int getCenterY(Rect rect) {
        return Math.round(rect.top + (rect.bottom - rect.top) / 2);
    }//from   w  ww  .j a v  a 2s .co m

    public static float getCenterY(RectF rect) {
        return (rect.top + (rect.bottom - rect.top) / 2);
    }
}

Related Tutorials