diff --git a/src/cheogram/java/com/cheogram/android/Util.java b/src/cheogram/java/com/cheogram/android/Util.java index 8683a801397b6e0fe63208032410185b642ad65b..1211141f18ae19770e1ef72dcf70b8882178e589 100644 --- a/src/cheogram/java/com/cheogram/android/Util.java +++ b/src/cheogram/java/com/cheogram/android/Util.java @@ -1,6 +1,7 @@ package com.cheogram.android; import android.view.View; +import android.view.View.MeasureSpec; import android.view.ViewGroup; import android.widget.ListView; import android.widget.ListAdapter; @@ -14,9 +15,11 @@ public class Util { } ViewGroup vg = listView; int totalHeight = 0; + final int width = listView.getWidth() > 0 ? listView.getWidth() : listView.getContext().getResources().getDisplayMetrics().widthPixels; + final int widthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST); for (int i = 0; i < adapter.getCount(); i++) { View listItem = adapter.getView(i, null, vg); - listItem.measure(0, 0); + listItem.measure(widthSpec, 0); totalHeight += listItem.getMeasuredHeight(); }