Android: Dynamic column number in GridView and Gridlayout manager

If you want to change grid item dynamically then follow these steps. This will help you to achieve your goal. For GridView just do : final GridView gridView = (GridView) rootView.findViewById(; int gridViewEntrySize = getResources().getDimensionPixelSize(R.dimen.grip_view_entry_size); int gridViewSpacing = getResources().getDimensionPixelSize(R.dimen.grip_view_spacing); WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int numColumns = (display.getWidth() – gridViewSpacing) / […]