Android examples for User Interface:View
View wait For Measure
import android.view.View; import android.view.ViewTreeObserver; public class Main{ public static void waitForMeasure(final View view, final OnMeasuredCallback callback) { int width = view.getWidth(); int height = view.getHeight(); if (width > 0 && height > 0) { callback.onMeasured(view, width, height); return; }/*from w ww. j a v a 2 s. c o m*/ view.getViewTreeObserver().addOnPreDrawListener( new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { final ViewTreeObserver observer = view .getViewTreeObserver(); if (observer.isAlive()) { observer.removeOnPreDrawListener(this); } callback.onMeasured(view, view.getWidth(), view.getHeight()); return true; } }); } }