Android examples for User Interface:GridView
get GridView Width
//package com.java2s; import android.annotation.SuppressLint; import android.view.View; import android.widget.GridView; import android.widget.ListAdapter; public class Main { @SuppressLint("NewApi") public static int getGridViewWidth(GridView listView, int n) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return 0; }/*from w ww. j a v a 2s . c o m*/ int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredWidth(); } return totalHeight + 5; } }