Friday, 16 January 2015

get Views actual Height and width at run time.


view.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
viewHeightvisibleOpenBtn.getMeasuredHeight();
viewWidthvisibleOpenBtn.getMeasuredWidth();



/**
 * Calculate actual width height of views
 */
Final ViewTreeObserver observer = view.getViewTreeObserver();
observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
viewWidth = view.getWidth();
}
});

No comments:

Post a Comment