Android examples for android.widget:GridView
get GridView Height
import android.annotation.SuppressLint; import android.view.View; import android.widget.GridView; import android.widget.ListAdapter; public class Main { @SuppressLint("NewApi") public static int getGridViewHeight(GridView listView, int n) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return 0;//from w ww .j ava2 s. c o m } int totalHeight = 0; for (int i = 0; i < (listAdapter.getCount() + 1) / n; i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } return totalHeight + 5; } }