Android examples for User Interface:Layout
Register a callback to be invoked when the global layout state or the visibility of views within the view tree changes.
//package com.java2s; import android.view.View; import android.view.ViewTreeObserver; public class Main { /**/*from w w w . j av a 2 s . c o m*/ * Register a callback to be invoked when the global layout state or the visibility of views * within the view tree changes. * * @param v The View. * @param listener The callback to add. * @see #removeGlobalLayoutListener(View, ViewTreeObserver.OnGlobalLayoutListener). */ public static void addGlobalLayoutListener(View v, ViewTreeObserver.OnGlobalLayoutListener listener) { ViewTreeObserver observer = v.getViewTreeObserver(); if (observer == null || !observer.isAlive()) { return; } observer.addOnGlobalLayoutListener(listener); } }