diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 14:04:24 -0800 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 14:04:24 -0800 |
| commit | 076357b8567458d4b6dfdcf839ef751634cd2bfb (patch) | |
| tree | efbb2fd6f1dc67d2d606382fc3b82983e7cb2e1f /core/java/android/widget/GridView.java | |
| parent | 3dec7d563a2f3e1eb967ce2054a00b6620e3558c (diff) | |
auto import from //depot/cupcake/@132589
Diffstat (limited to 'core/java/android/widget/GridView.java')
| -rw-r--r-- | core/java/android/widget/GridView.java | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index 6bbf062c3afe..38bfc7c17b44 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -924,23 +924,32 @@ public class GridView extends AbsListView { final int count = mItemCount; if (count > 0) { final View child = obtainView(0); + final int childViewType = mAdapter.getItemViewType(0); - AbsListView.LayoutParams p = (AbsListView.LayoutParams)child.getLayoutParams(); - if (p == null) { - p = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, + AbsListView.LayoutParams lp = (AbsListView.LayoutParams) child.getLayoutParams(); + if (lp == null) { + lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0); + child.setLayoutParams(lp); } - p.viewType = mAdapter.getItemViewType(0); + lp.viewType = childViewType; - int childHeightSpec = getChildMeasureSpec( - MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 0, p.height); - int childWidthSpec = getChildMeasureSpec( - MeasureSpec.makeMeasureSpec(mColumnWidth, MeasureSpec.EXACTLY), 0, p.width); - child.measure(childWidthSpec, childHeightSpec); + final int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec, + mListPadding.left + mListPadding.right, lp.width); + + int lpHeight = lp.height; + int childHeightSpec; + if (lpHeight > 0) { + childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY); + } else { + childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + } + + child.measure(childWidthSpec, childHeightSpec); childHeight = child.getMeasuredHeight(); - if (mRecycler.shouldRecycleViewType(p.viewType)) { + if (mRecycler.shouldRecycleViewType(childViewType)) { mRecycler.addScrapView(child); } } |
