Skip to content

Commit

Permalink
* add new method to set the height for the normal header
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed May 10, 2016
1 parent 6ed3e06 commit 2675dff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.mikepenz.fastadapter.adapters.HeaderAdapter;
import com.mikepenz.fastadapter.adapters.ItemAdapter;
import com.mikepenz.iconics.utils.Utils;
import com.mikepenz.materialdrawer.holder.DimenHolder;
import com.mikepenz.materialdrawer.model.AbstractDrawerItem;
import com.mikepenz.materialdrawer.model.DividerDrawerItem;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
Expand Down Expand Up @@ -538,6 +539,7 @@ public DrawerBuilder withScrollToTopAfterClick(boolean scrollToTopAfterClick) {
protected View mHeaderView;
protected boolean mHeaderDivider = true;
protected boolean mHeaderPadding = true;
protected DimenHolder mHeiderHeight = null;

/**
* Add a header to the DrawerBuilder ListView. This can be any view
Expand Down Expand Up @@ -591,6 +593,17 @@ public DrawerBuilder withHeaderPadding(boolean headerPadding) {
return this;
}

/**
* Sets the header height for the header provided via `withHeader()`
*
* @param headerHeight the DimenHolder with the height we want to set for the header
* @return
*/
public DrawerBuilder withHeaderHeight(DimenHolder headerHeight) {
this.mHeiderHeight = headerHeight;
return this;
}

// sticky view
protected View mStickyHeaderView;
// shadow shown on the top of the sticky header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ public static void handleHeaderView(DrawerBuilder drawer) {
}

if (drawer.mHeaderPadding) {
drawer.getHeaderAdapter().add(new ContainerDrawerItem().withView(drawer.mHeaderView).withDivider(drawer.mHeaderDivider).withViewPosition(ContainerDrawerItem.Position.TOP));
drawer.getHeaderAdapter().add(new ContainerDrawerItem().withView(drawer.mHeaderView).withHeight(drawer.mHeiderHeight).withDivider(drawer.mHeaderDivider).withViewPosition(ContainerDrawerItem.Position.TOP));
} else {
drawer.getHeaderAdapter().add(new ContainerDrawerItem().withView(drawer.mHeaderView).withDivider(drawer.mHeaderDivider).withViewPosition(ContainerDrawerItem.Position.NONE));
drawer.getHeaderAdapter().add(new ContainerDrawerItem().withView(drawer.mHeaderView).withHeight(drawer.mHeiderHeight).withDivider(drawer.mHeaderDivider).withViewPosition(ContainerDrawerItem.Position.NONE));
}
//set the padding on the top to 0
drawer.mRecyclerView.setPadding(drawer.mRecyclerView.getPaddingLeft(), 0, drawer.mRecyclerView.getPaddingRight(), drawer.mRecyclerView.getPaddingBottom());
Expand Down

0 comments on commit 2675dff

Please sign in to comment.