is View In Visible - Android User Interface

Android examples for User Interface:View Hide Show

Description

is View In Visible

Demo Code


//package com.java2s;

import android.view.View;

public class Main {
    static int screenHeight = -1;
    static int[] location = new int[2];

    public static boolean isInVisible(View view) {
        if (screenHeight == -1) {
            screenHeight = view.getContext().getResources()
                    .getDisplayMetrics().heightPixels;
        }//w  w w  .  j  a v a 2  s .com

        view.getLocationOnScreen(location);
        int left = location[0];
        int top = location[1];
        int height = view.getHeight();

        //in top
        if ((top + height) < -0.5 * screenHeight) {
            return true;
        }

        //in bottom
        if (top > screenHeight + 0.5 * screenHeight) {
            return true;
        }

        return false;
    }
}

Related Tutorials