If I call getMeasuredWidth() or getWidth() for layout in onResume they returns 0. I think that view it\'s not drawn yet in this moment.
Also I think that I need to
This answer says:
Use the ViewTreeObserver on the View to wait for the first layout. Only after the first layout will getWidth()/getHeight()/getMeasuredWidth()/getMeasuredHeight() work.
ViewTreeObserver viewTreeObserver = view.getViewTreeObserver();
if (viewTreeObserver.isAlive()) {
viewTreeObserver.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
viewWidth = mediaGallery.getWidth();
viewHeight = mediaGallery.getHeight();
}
});
}