In my application i have gridview in linearlayout. Due to different sizes of screen, i want to calculate the width of the gridview's container (which in linearlayout) and then i will decide, how many column should display on screen. My problem is. when i write
linearlayout.getwidth();
it returns 0 and its because its too early to get size of view in oncreate method.
What is the clean solution to get height or width of the view.
i tried
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int gridSize = display.getWidth();
but android says its deprecated :(