修改参考:android 8.1 Launcher3 横屏状态长按图标 弹框位置居中分析
--- a/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/popup/ArrowPopup.java
+++ b/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/popup/ArrowPopup.java
@@ -257,6 +257,15 @@ public abstract class ArrowPopup extends AbstractFloatingView {
}
x += mIsLeftAligned ? xOffset : -xOffset;
+ int shortcutItemWidth =
+ resources.getDimensionPixelSize(R.dimen.bg_popup_item_width);
+ if( x + shortcutItemWidth > dragLayer.getWidth()){
+ mIsLeftAligned = false;
+ x = x - shortcutItemWidth + xOffset;
+ }
+
// Open above icon if there is room.
int iconHeight = mTempRect.height();
int y = mTempRect.top - height;