diff --git a/quickstep/res/layout/task_menu_with_arrow.xml b/quickstep/res/layout/task_menu_with_arrow.xml
index 38573fd1e5..c9108a5abd 100644
--- a/quickstep/res/layout/task_menu_with_arrow.xml
+++ b/quickstep/res/layout/task_menu_with_arrow.xml
@@ -23,11 +23,17 @@
android:orientation="vertical"
android:visibility="invisible">
-
+ android:layout_height="wrap_content">
+
+
+
+
\ No newline at end of file
diff --git a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
index 0476fe80d6..1be908be10 100644
--- a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
+++ b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
@@ -213,7 +213,8 @@ public class PortraitPagedViewHandler extends DefaultPagedViewHandler implements
@Override
public int getTaskMenuHeight(float taskInsetMargin, DeviceProfile deviceProfile,
float taskMenuX, float taskMenuY) {
- return (int) (deviceProfile.availableHeightPx - taskInsetMargin - taskMenuY);
+ return (int) (deviceProfile.heightPx - deviceProfile.getInsets().top - taskMenuY
+ - deviceProfile.getOverviewActionsClaimedSpaceBelow());
}
@Override
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt
index 12b8b6f555..dcf681c345 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt
@@ -124,6 +124,25 @@ class TaskMenuViewWithArrow : ArrowPopup {
optionLayout = requireViewById(R.id.menu_option_layout)
}
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
+ val maxMenuHeight: Int = calculateMaxHeight()
+ val newHeightMeasureSpec =
+ if (MeasureSpec.getSize(heightMeasureSpec) > maxMenuHeight) {
+ MeasureSpec.makeMeasureSpec(maxMenuHeight, MeasureSpec.AT_MOST)
+ } else heightMeasureSpec
+ super.onMeasure(widthMeasureSpec, newHeightMeasureSpec)
+ }
+
+ private fun calculateMaxHeight(): Int {
+ val taskInsetMargin = resources.getDimension(R.dimen.task_card_margin)
+ return taskView.pagedOrientationHandler.getTaskMenuHeight(
+ taskInsetMargin,
+ mActivityContext.deviceProfile,
+ translationX,
+ translationY
+ )
+ }
+
private fun populateAndShowForTask(
taskContainer: TaskIdAttributeContainer,
alignedOptionIndex: Int