List of usage examples for android.widget LinearLayout getPaddingTop
public int getPaddingTop()
From source file:cx.ring.fragments.CallListFragment.java
public void setGridViewHeight(GridView gridView, LinearLayout llMain) { ListAdapter listAdapter = gridView.getAdapter(); if (listAdapter == null) { return;/*from w ww.j av a2 s .c o m*/ } int totalHeight = 0; int firstHeight = 0; int desiredWidth = View.MeasureSpec.makeMeasureSpec(gridView.getWidth(), View.MeasureSpec.AT_MOST); int rows = (listAdapter.getCount() + gridView.getNumColumns() - 1) / gridView.getNumColumns(); for (int i = 0; i < rows; i++) { if (i == 0) { View listItem = listAdapter.getView(i, null, gridView); listItem.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED); firstHeight = listItem.getMeasuredHeight(); } totalHeight += firstHeight; } LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) llMain.getLayoutParams(); params.height = (int) (totalHeight + (getResources().getDimension(R.dimen.contact_vertical_spacing) * (rows - 1) + llMain.getPaddingBottom() + llMain.getPaddingTop())); llMain.setLayoutParams(params); mHeader.requestLayout(); }