Skip to content

Commit

Permalink
Fix bauerca#59: dynamic list item heights
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bauerca committed Jan 13, 2013
1 parent ec55b6f commit 6afde13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library/src/com/mobeta/android/dslv/DragSortItemView.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public DragSortItemView(Context context) {
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));

setClipChildren(true);
//setClipChildren(true);
}

public void setGravity(int gravity) {
Expand Down
9 changes: 6 additions & 3 deletions library/src/com/mobeta/android/dslv/DragSortListView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1729,17 +1729,20 @@ private void adjustItem(int position) {
private void adjustItem(int position, View v, boolean invalidChildHeight) {

// Adjust item height

int height = calcItemHeight(position, v, invalidChildHeight);
ViewGroup.LayoutParams lp = v.getLayoutParams();
int height;
if (position != mSrcPos && position != mFirstExpPos && position != mSecondExpPos) {
height = ViewGroup.LayoutParams.WRAP_CONTENT;
} else {
height = calcItemHeight(position, v, invalidChildHeight);
}

if (height != lp.height) {
lp.height = height;
v.setLayoutParams(lp);
}

// Adjust item gravity

if (position == mFirstExpPos || position == mSecondExpPos) {
if (position < mSrcPos) {
((DragSortItemView) v).setGravity(Gravity.BOTTOM);
Expand Down

0 comments on commit 6afde13

Please sign in to comment.