@@ -16,8 +16,8 @@
 
 package com.tonicartos.widget.stickygridheaders;
 
-import com.tonicartos.widget.stickygridheaders.StickyGridHeadersBaseAdapterWrapper.HeaderFillerView;
-import com.tonicartos.widget.stickygridheaders.StickyGridHeadersBaseAdapterWrapper.ReferenceView;
+import java.util.ArrayList;
+import java.util.List;
 
 import android.content.Context;
 import android.database.DataSetObserver;
@@ -44,8 +44,8 @@
 import android.widget.GridView;
 import android.widget.ListAdapter;
 
-import java.util.ArrayList;
-import java.util.List;
+import com.tonicartos.widget.stickygridheaders.StickyGridHeadersBaseAdapterWrapper.HeaderFillerView;
+import com.tonicartos.widget.stickygridheaders.StickyGridHeadersBaseAdapterWrapper.ReferenceView;
 
 /**
  * GridView that displays items in sections with headers that stick to the top
@@ -112,6 +112,7 @@ public void onInvalidated() {
     protected int mMotionHeaderPosition;
     protected int mTouchMode;
     private boolean mMaskStickyHeaderRegion = true;
+	private boolean mHeadersIgnorePadding;
 
     public StickyGridHeadersGridView(Context context) {
         this(context, null);
@@ -528,9 +529,14 @@ private void measureHeader() {
         if (mStickiedHeader == null) {
             return;
         }
-
-        int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth()
-                - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY);
+        
+        int widthMeasureSpec;
+        if (mHeadersIgnorePadding) {
+        	widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY);
+        } else {
+        	widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth()
+                     - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY);
+        }
         int heightMeasureSpec = 0;
 
         ViewGroup.LayoutParams params = mStickiedHeader.getLayoutParams();
@@ -542,8 +548,22 @@ private void measureHeader() {
                     MeasureSpec.UNSPECIFIED);
         }
         mStickiedHeader.measure(widthMeasureSpec, heightMeasureSpec);
-        mStickiedHeader.layout(getLeft() + getPaddingLeft(), 0, getRight()
-                - getPaddingRight(), mStickiedHeader.getMeasuredHeight());
+        
+        if (mHeadersIgnorePadding) {
+        	mStickiedHeader.layout(getLeft(), 0, getRight(), mStickiedHeader.getMeasuredHeight());
+        } else {
+        	mStickiedHeader.layout(getLeft() + getPaddingLeft(), 0, getRight()
+                    - getPaddingRight(), mStickiedHeader.getMeasuredHeight());        	
+        }
+    }
+    
+    
+    /**
+     * If set to true, headers will ignore horizontal padding.
+     * @param b if true, horizontal padding is ignored by headers
+     */
+    public void setHeadersIgnorePadding (boolean b) {
+    	mHeadersIgnorePadding = b;
     }
 
     private void reset() {
@@ -676,8 +696,13 @@ protected void dispatchDraw(Canvas canvas) {
         // Mask the region where we will draw the header later, but only if we
         // will draw a header and masking is requested.
         if (drawStickiedHeader && mMaskStickyHeaderRegion) {
-            mClippingRect.left = getPaddingLeft();
-            mClippingRect.right = getWidth() - getPaddingRight();
+        	if (mHeadersIgnorePadding) {
+        		mClippingRect.left = 0;
+        		mClippingRect.right = getWidth();
+        	} else {
+        		mClippingRect.left = getPaddingLeft();
+        		mClippingRect.right = getWidth() - getPaddingRight();
+        	}
             mClippingRect.top = mHeaderBottomPosition;
             mClippingRect.bottom = getHeight();
 
@@ -718,21 +743,41 @@ protected void dispatchDraw(Canvas canvas) {
             if (header.getVisibility() != View.VISIBLE || headerIsStickied) {
                 continue;
             }
-            int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),
-                    MeasureSpec.EXACTLY - getPaddingLeft() - getPaddingRight());
+            int widthMeasureSpec;
+            
+            if (mHeadersIgnorePadding) {
+            	widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),
+                    MeasureSpec.EXACTLY);
+            } else {
+            	widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),
+                        MeasureSpec.EXACTLY - getPaddingLeft() - getPaddingRight());            	
+            }
             int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,
                     MeasureSpec.UNSPECIFIED);
             header.measure(widthMeasureSpec, heightMeasureSpec);
-            header.layout(getLeft() + getPaddingLeft(), 0, getRight()
-                    - getPaddingRight(), frame.getHeight());
-
-            mClippingRect.left = getPaddingLeft();
-            mClippingRect.right = getWidth() - getPaddingRight();
+            if (mHeadersIgnorePadding) {
+            	header.layout(getLeft(), 0, getRight(), frame.getHeight());
+            } else {
+            	header.layout(getLeft() + getPaddingLeft(), 0, getRight()
+            			- getPaddingRight(), frame.getHeight());
+            }
+            
+            if (mHeadersIgnorePadding) {
+            	mClippingRect.left = 0;
+            	mClippingRect.right = getWidth();
+            } else {
+            	mClippingRect.left = getPaddingLeft();
+            	mClippingRect.right = getWidth() - getPaddingRight();
+            }
             mClippingRect.bottom = frame.getBottom();
             mClippingRect.top = frame.getTop();
             canvas.save();
             canvas.clipRect(mClippingRect);
-            canvas.translate(getPaddingLeft(), frame.getTop());
+            if (mHeadersIgnorePadding) {
+            	canvas.translate(0, frame.getTop());
+            } else {
+            	canvas.translate(getPaddingLeft(), frame.getTop());
+            }
             header.draw(canvas);
             canvas.restore();
         }
@@ -745,19 +790,40 @@ protected void dispatchDraw(Canvas canvas) {
         }
 
         // Draw stickied header.
-        if (mStickiedHeader.getWidth() != getWidth() - getPaddingLeft()
-                - getPaddingRight()) {
-            int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),
-                    MeasureSpec.EXACTLY - getPaddingLeft() - getPaddingRight());
+        int wantedWidth;
+        if (mHeadersIgnorePadding) {
+        	wantedWidth = getWidth();
+        } else {
+        	wantedWidth = getWidth() - getPaddingLeft()
+                    - getPaddingRight();
+        }
+        if (mStickiedHeader.getWidth() != wantedWidth) {
+        	int widthMeasureSpec; 
+        	if (mHeadersIgnorePadding) {
+        		widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),
+        				MeasureSpec.EXACTLY);
+        	} else {
+        		widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth() - getPaddingLeft() - getPaddingRight(),
+        				MeasureSpec.EXACTLY);        		// Bug here
+        	}
             int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,
                     MeasureSpec.UNSPECIFIED);
             mStickiedHeader.measure(widthMeasureSpec, heightMeasureSpec);
-            mStickiedHeader.layout(getLeft() + getPaddingLeft(), 0, getRight()
-                    - getPaddingRight(), mStickiedHeader.getHeight());
+            if (mHeadersIgnorePadding) {
+            	mStickiedHeader.layout(getLeft(), 0, getRight(), mStickiedHeader.getHeight());
+            } else {
+            	mStickiedHeader.layout(getLeft() + getPaddingLeft(), 0, getRight()
+            			- getPaddingRight(), mStickiedHeader.getHeight());            	
+            }
         }
 
-        mClippingRect.left = getPaddingLeft();
-        mClippingRect.right = getWidth() - getPaddingRight();
+        if (mHeadersIgnorePadding) {
+        	mClippingRect.left = 0;
+        	mClippingRect.right = getWidth();
+        } else {
+        	mClippingRect.left = getPaddingLeft();
+        	mClippingRect.right = getWidth() - getPaddingRight();
+        }
         mClippingRect.bottom = top + headerHeight;
         if (mClippingToPadding) {
             mClippingRect.top = getPaddingTop();
@@ -767,7 +833,11 @@ protected void dispatchDraw(Canvas canvas) {
 
         canvas.save();
         canvas.clipRect(mClippingRect);
-        canvas.translate(getPaddingLeft(), top);
+        if (mHeadersIgnorePadding) {
+        	canvas.translate(0, top);
+        } else {
+        	canvas.translate(getPaddingLeft(), top);
+        }
         canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(),
                 (int)(0xff * (float)mHeaderBottomPosition / headerHeight),
                 Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);