Update calculation method for Overview UI placement on tablets

This update slightly changes the calculation method for Overview UI placement, in order to line up better with spec. (The previous calculation caused a small 30dp divergence on tablets.)

Bug: 236760307
Test: Manual by measuring pixels and comparing to spec
Change-Id: I94e9e7b5a6a24c37693425ac8ec71cd066003658
diff --git a/quickstep/res/values-sw600dp/dimens.xml b/quickstep/res/values-sw600dp/dimens.xml
index 7494683..cfbbf8d 100644
--- a/quickstep/res/values-sw600dp/dimens.xml
+++ b/quickstep/res/values-sw600dp/dimens.xml
@@ -14,16 +14,23 @@
  * limitations under the License.
 */
 -->
+<!-- Applies to small tablet screens -->
 <resources>
     <dimen name="navigation_key_padding">25dp</dimen>
 
-    <!--  Task View  -->
+    <!--  Overview Task Views  -->
+    <!--  A touch target for icons, sometimes slightly larger than the icons themselves  -->
     <dimen name="task_thumbnail_icon_size">48dp</dimen>
+    <!--  The icon size for the focused task, placed in center of touch target  -->
     <dimen name="task_thumbnail_icon_drawable_size">44dp</dimen>
+    <!--  The space under the focused task icon  -->
     <dimen name="overview_task_margin">12dp</dimen>
+    <!--  The icon size of all non-focused task icons, placed in center of touch target  -->
     <dimen name="task_thumbnail_icon_drawable_size_grid">44dp</dimen>
-    <dimen name="overview_task_margin_grid">12dp</dimen>
+    <!--  The space between grid rows (when there's 2 rows of thumbnails)  -->
     <dimen name="overview_grid_row_spacing">28dp</dimen>
+    <!--  The horizontal space between tasks  -->
     <dimen name="overview_page_spacing">36dp</dimen>
+    <!--  The space to the left and to the right of the "Clear all" button  -->
     <dimen name="overview_grid_side_margin">64dp</dimen>
 </resources>
diff --git a/quickstep/res/values-sw720dp/dimens.xml b/quickstep/res/values-sw720dp/dimens.xml
index ceaa8f8..284ce11 100644
--- a/quickstep/res/values-sw720dp/dimens.xml
+++ b/quickstep/res/values-sw720dp/dimens.xml
@@ -14,14 +14,23 @@
  * limitations under the License.
 */
 -->
+<!-- Applies to large tablet screens -->
 <resources>
-    <!--  Task View  -->
+    <!--  Overview Task Views  -->
+    <!--  The primary task thumbnail uses up to this much of the total screen height/width  -->
+    <item name="overview_max_scale" format="float" type="dimen">0.7</item>
+    <!--  A touch target for icons, sometimes slightly larger than the icons themselves  -->
     <dimen name="task_thumbnail_icon_size">48dp</dimen>
+    <!--  The icon size for the focused task, placed in center of touch target  -->
     <dimen name="task_thumbnail_icon_drawable_size">44dp</dimen>
+    <!--  The space under the focused task icon  -->
     <dimen name="overview_task_margin">16dp</dimen>
+    <!--  The icon size of all non-focused task icons, placed in center of touch target  -->
     <dimen name="task_thumbnail_icon_drawable_size_grid">44dp</dimen>
-    <dimen name="overview_task_margin_grid">16dp</dimen>
+    <!--  The space between grid rows (when there's 2 rows of thumbnails)  -->
     <dimen name="overview_grid_row_spacing">36dp</dimen>
+    <!--  The horizontal space between tasks  -->
     <dimen name="overview_page_spacing">44dp</dimen>
+    <!--  The space to the left and to the right of the "Clear all" button  -->
     <dimen name="overview_grid_side_margin">64dp</dimen>
 </resources>
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 0232f86..35215e1 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -31,14 +31,19 @@
 
     <dimen name="overview_minimum_next_prev_size">50dp</dimen>
 
-    <!--  Task View  -->
-    <dimen name="task_thumbnail_icon_size">48dp</dimen>
-    <dimen name="task_thumbnail_icon_drawable_size">44dp</dimen>
-    <dimen name="overview_task_margin">16dp</dimen>
-    <dimen name="overview_page_spacing">16dp</dimen>
-    <dimen name="task_icon_cache_default_icon_size">72dp</dimen>
-
+    <!--  Overview Task Views  -->
+    <!--  The primary task thumbnail uses up to this much of the total screen height/width  -->
     <item name="overview_max_scale" format="float" type="dimen">0.7</item>
+    <!--  A touch target for icons, sometimes slightly larger than the icons themselves  -->
+    <dimen name="task_thumbnail_icon_size">48dp</dimen>
+    <!--  The icon size for the focused task, placed in center of touch target  -->
+    <dimen name="task_thumbnail_icon_drawable_size">44dp</dimen>
+    <!--  The space under the focused task icon  -->
+    <dimen name="overview_task_margin">16dp</dimen>
+    <!--  The horizontal space between tasks  -->
+    <dimen name="overview_page_spacing">16dp</dimen>
+
+    <dimen name="task_icon_cache_default_icon_size">72dp</dimen>
     <item name="overview_modal_max_scale" format="float" type="dimen">1.1</item>
 
     <!-- Overrideable in overlay that provides the Overview Actions. -->
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 5602d88..d52faad 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -866,10 +866,9 @@
 
         int thumbnailTopMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
         int taskIconHeight = deviceProfile.overviewTaskIconSizePx;
-        int taskMargin = isGridTask ? deviceProfile.overviewTaskMarginGridPx
-                : deviceProfile.overviewTaskMarginPx;
-        int taskIconMargin = thumbnailTopMargin - taskIconHeight - taskMargin;
-        orientationHandler.setTaskIconParams(iconParams, taskIconMargin, taskIconHeight,
+        int taskMargin = deviceProfile.overviewTaskMarginPx;
+
+        orientationHandler.setTaskIconParams(iconParams, taskMargin, taskIconHeight,
                 thumbnailTopMargin, isRtl);
         iconParams.width = iconParams.height = taskIconHeight;
         mIconView.setLayoutParams(iconParams);
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfilePhone3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfilePhone3ButtonTest.kt
index 3daf81d..f41de72 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfilePhone3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfilePhone3ButtonTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(0)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(168)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(280)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(224)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(-112)
+        assertThat(dp.overviewRowSpacing).isEqualTo(0)
     }
 
     @Test
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfilePhoneTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfilePhoneTest.kt
index e588c71..fe3fd00 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfilePhoneTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfilePhoneTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(0)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(168)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(280)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(224)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(-112)
+        assertThat(dp.overviewRowSpacing).isEqualTo(0)
     }
 
     @Test
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt
index d0c9346..33866f0 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(32)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(96)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(160)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(128)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(40)
+        assertThat(dp.overviewRowSpacing).isEqualTo(72)
     }
 
     @Test
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscapeTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscapeTest.kt
index 456ed2c..e61a890 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscapeTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscapeTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(32)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(96)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(160)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(128)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(40)
+        assertThat(dp.overviewRowSpacing).isEqualTo(72)
     }
 
     @Test
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt
index eed3598..3f350de 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(32)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(96)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(160)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(128)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(40)
+        assertThat(dp.overviewRowSpacing).isEqualTo(72)
     }
 
     @Test
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortraitTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortraitTest.kt
index 4be3e45..444f7ea 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortraitTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortraitTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(32)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(96)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(160)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(128)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(40)
+        assertThat(dp.overviewRowSpacing).isEqualTo(72)
     }
 
     @Test
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt
index 6728540..92ab2b1 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(32)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(96)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(160)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(128)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(40)
+        assertThat(dp.overviewRowSpacing).isEqualTo(72)
     }
 
     @Test
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscapeTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscapeTest.kt
index ba3ef55..6c730ca 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscapeTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscapeTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(32)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(96)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(160)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(128)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(40)
+        assertThat(dp.overviewRowSpacing).isEqualTo(72)
     }
 
     @Test
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt
index a4b446a..9048b3b 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(32)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(96)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(160)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(128)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(40)
+        assertThat(dp.overviewRowSpacing).isEqualTo(72)
     }
 
     @Test
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortraitTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortraitTest.kt
index 0c5968e..b737c3a 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortraitTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortraitTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(32)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(96)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(160)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(128)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(40)
+        assertThat(dp.overviewRowSpacing).isEqualTo(72)
     }
 
     @Test
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBar3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBar3ButtonTest.kt
index 2bad6bb..d90f56b 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBar3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBar3ButtonTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(0)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(168)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(280)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(224)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(-112)
+        assertThat(dp.overviewRowSpacing).isEqualTo(0)
     }
 
     @Test
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBarTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBarTest.kt
index 6256a43..522a650 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBarTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBarTest.kt
@@ -340,11 +340,6 @@
     }
 
     @Test
-    fun overviewTaskMarginGridPx() {
-        assertThat(dp.overviewTaskMarginGridPx).isEqualTo(0)
-    }
-
-    @Test
     fun overviewTaskIconSizePx() {
         assertThat(dp.overviewTaskIconSizePx).isEqualTo(168)
     }
@@ -361,7 +356,7 @@
 
     @Test
     fun overviewTaskThumbnailTopMarginPx() {
-        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(280)
+        assertThat(dp.overviewTaskThumbnailTopMarginPx).isEqualTo(224)
     }
 
     @Test
@@ -386,7 +381,7 @@
 
     @Test
     fun overviewRowSpacing() {
-        assertThat(dp.overviewRowSpacing).isEqualTo(-112)
+        assertThat(dp.overviewRowSpacing).isEqualTo(0)
     }
 
     @Test
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index b19e739..29bc170 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -381,7 +381,6 @@
     <dimen name="task_thumbnail_icon_drawable_size">0dp</dimen>
     <dimen name="task_thumbnail_icon_drawable_size_grid">0dp</dimen>
     <dimen name="overview_task_margin">0dp</dimen>
-    <dimen name="overview_task_margin_grid">0dp</dimen>
     <dimen name="overview_actions_height">0dp</dimen>
     <dimen name="overview_actions_button_spacing">0dp</dimen>
     <dimen name="overview_actions_margin_gesture">0dp</dimen>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 3a2227a..3611b8a 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -191,7 +191,6 @@
 
     // Overview
     public int overviewTaskMarginPx;
-    public int overviewTaskMarginGridPx;
     public int overviewTaskIconSizePx;
     public int overviewTaskIconDrawableSizePx;
     public int overviewTaskIconDrawableSizeGridPx;
@@ -426,25 +425,18 @@
         }
 
         overviewTaskMarginPx = res.getDimensionPixelSize(R.dimen.overview_task_margin);
-        overviewTaskMarginGridPx = res.getDimensionPixelSize(R.dimen.overview_task_margin_grid);
         overviewTaskIconSizePx = res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_size);
         overviewTaskIconDrawableSizePx =
                 res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_drawable_size);
         overviewTaskIconDrawableSizeGridPx =
                 res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_drawable_size_grid);
-        overviewTaskThumbnailTopMarginPx = overviewTaskIconSizePx + overviewTaskMarginPx * 2;
+        overviewTaskThumbnailTopMarginPx = overviewTaskIconSizePx + overviewTaskMarginPx;
         overviewActionsTopMarginPx = res.getDimensionPixelSize(R.dimen.overview_actions_top_margin);
         overviewPageSpacing = res.getDimensionPixelSize(R.dimen.overview_page_spacing);
         overviewActionsButtonSpacing = res.getDimensionPixelSize(
                 R.dimen.overview_actions_button_spacing);
         overviewActionsHeight = res.getDimensionPixelSize(R.dimen.overview_actions_height);
-        // Grid task's top margin is only overviewTaskIconSizePx + overviewTaskMarginGridPx, but
-        // overviewTaskThumbnailTopMarginPx is applied to all TaskThumbnailView, so exclude the
-        // extra  margin when calculating row spacing.
-        int extraTopMargin = overviewTaskThumbnailTopMarginPx - overviewTaskIconSizePx
-                - overviewTaskMarginGridPx;
-        overviewRowSpacing = res.getDimensionPixelSize(R.dimen.overview_grid_row_spacing)
-                - extraTopMargin;
+        overviewRowSpacing = res.getDimensionPixelSize(R.dimen.overview_grid_row_spacing);
         overviewGridSideMargin = res.getDimensionPixelSize(R.dimen.overview_grid_side_margin);
 
         // Calculate all of the remaining variables.
@@ -1379,7 +1371,6 @@
         writer.println(prefix + pxToDpStr("workspaceBottomPadding", workspaceBottomPadding));
 
         writer.println(prefix + pxToDpStr("overviewTaskMarginPx", overviewTaskMarginPx));
-        writer.println(prefix + pxToDpStr("overviewTaskMarginGridPx", overviewTaskMarginGridPx));
         writer.println(prefix + pxToDpStr("overviewTaskIconSizePx", overviewTaskIconSizePx));
         writer.println(prefix + pxToDpStr("overviewTaskIconDrawableSizePx",
                 overviewTaskIconDrawableSizePx));
diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
index fa4eb70..e3cdee4 100644
--- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
@@ -523,6 +523,7 @@
         iconParams.rightMargin = -taskIconHeight - taskIconMargin / 2;
         iconParams.leftMargin = 0;
         iconParams.topMargin = thumbnailTopMargin / 2;
+        iconParams.bottomMargin = 0;
     }
 
     @Override
diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
index 181dca5..738e6b1 100644
--- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
+++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
@@ -52,9 +52,9 @@
 import com.android.launcher3.Utilities;
 import com.android.launcher3.util.DisplayController;
 import com.android.launcher3.util.SplitConfigurationOptions;
+import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds;
 import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
 import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
-import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds;
 import com.android.launcher3.views.BaseDragLayer;
 
 import java.util.List;
@@ -658,8 +658,9 @@
     public void setTaskIconParams(FrameLayout.LayoutParams iconParams, int taskIconMargin,
             int taskIconHeight, int thumbnailTopMargin, boolean isRtl) {
         iconParams.gravity = TOP | CENTER_HORIZONTAL;
+        // Reset margins, since they may have been set on rotation
         iconParams.leftMargin = iconParams.rightMargin = 0;
-        iconParams.topMargin = taskIconMargin;
+        iconParams.topMargin = iconParams.bottomMargin = 0;
     }
 
     @Override
diff --git a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java
index 339f910..387e980 100644
--- a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java
@@ -216,6 +216,7 @@
         iconParams.leftMargin = -taskIconHeight - taskIconMargin / 2;
         iconParams.rightMargin = 0;
         iconParams.topMargin = thumbnailTopMargin / 2;
+        iconParams.bottomMargin = 0;
     }
 
     @Override