protected int getRowWidth(int columnSpan) { final int rowWidth = listView.getColumnWidth() * columnSpan; // when the item spans multiple columns, we need to account for the horizontal padding // and add that to the total final width return Math.min( rowWidth + ((columnSpan - 1) * listView.getRequestedHorizontalSpacing()), Utils.getScreenWidth(getContext())); }
public AsymmetricGridView(final Context context, final AttributeSet attrs) { super(context, attrs); defaultPadding = Utils.dpToPx(context, 5); requestedHorizontalSpacing = defaultPadding; requestedVerticalSpacing = defaultPadding; padding = new Rect(defaultPadding, defaultPadding, defaultPadding, defaultPadding); final ViewTreeObserver vto = getViewTreeObserver(); if (vto != null) vto.addOnPreDrawListener( new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { getViewTreeObserver().removeOnPreDrawListener(this); determineColumns(); if (gridAdapter != null) gridAdapter.notifyDataSetChanged(); return false; } }); }