Merge "Fix widget span" into tm-dev am: ec3723beb1

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/18579283

Change-Id: I4d8be05de0358c94d2f401db6bd7b579d4a2aca2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java
index 1bcba14..8962c4f 100644
--- a/src/com/android/launcher3/widget/BaseWidgetSheet.java
+++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java
@@ -198,7 +198,9 @@
     /** Returns the number of cells that can fit horizontally in a given {@code content}. */
     protected int computeMaxHorizontalSpans(View content, int contentHorizontalPaddingPx) {
         DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
-        int availableWidth = content.getMeasuredWidth() - contentHorizontalPaddingPx;
+        int availableWidth = content.getMeasuredWidth()
+                - contentHorizontalPaddingPx
+                - (2 * mContentHorizontalMarginInPx);
         Point cellSize = deviceProfile.getCellSize();
         if (cellSize.x > 0) {
             return availableWidth / cellSize.x;