Skip to content

Commit 6afde13

Browse files
committed
Fix bauerca#59: dynamic list item heights
Set DragSortItemView layout param height to WRAP_CONTENT when it is not a special expanded/collapsed item. This way, ListView creates the appropriate height MeasureSpec while laying out items.
1 parent ec55b6f commit 6afde13

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

library/src/com/mobeta/android/dslv/DragSortItemView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public DragSortItemView(Context context) {
3636
ViewGroup.LayoutParams.FILL_PARENT,
3737
ViewGroup.LayoutParams.WRAP_CONTENT));
3838

39-
setClipChildren(true);
39+
//setClipChildren(true);
4040
}
4141

4242
public void setGravity(int gravity) {

library/src/com/mobeta/android/dslv/DragSortListView.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,17 +1729,20 @@ private void adjustItem(int position) {
17291729
private void adjustItem(int position, View v, boolean invalidChildHeight) {
17301730

17311731
// Adjust item height
1732-
1733-
int height = calcItemHeight(position, v, invalidChildHeight);
17341732
ViewGroup.LayoutParams lp = v.getLayoutParams();
1733+
int height;
1734+
if (position != mSrcPos && position != mFirstExpPos && position != mSecondExpPos) {
1735+
height = ViewGroup.LayoutParams.WRAP_CONTENT;
1736+
} else {
1737+
height = calcItemHeight(position, v, invalidChildHeight);
1738+
}
17351739

17361740
if (height != lp.height) {
17371741
lp.height = height;
17381742
v.setLayoutParams(lp);
17391743
}
17401744

17411745
// Adjust item gravity
1742-
17431746
if (position == mFirstExpPos || position == mSecondExpPos) {
17441747
if (position < mSrcPos) {
17451748
((DragSortItemView) v).setGravity(Gravity.BOTTOM);

0 commit comments

Comments
 (0)