you will not get value unitl onCreate
finishes.so add these in onResume()
or in onStart()
int height= li.getHeight();
int width = li.getWidth();
the other option is to use globallayoutlistener
(if you want to get height in onCreate) so you will get notified when li(your layout) is added.
ViewTreeObserver observer= li.getViewTreeObserver();
observer.addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Log.d("Log", "Height: " + li.getHeight());
Log.d("Log", "Width: " + li.getWidth());
}
});