0

As we see above am using ListPopupWindow to show a popup list that display 3 items and am initializing it using the below code:

    mPopupAdapter = new PopupWindowAdapter(LauncherActivity.this, microapps);
    mPopupWindow = new ListPopupWindow(LauncherActivity.this);
    mPopupWindow.setAdapter(mPopupAdapter);
    mPopupWindow.setAnchorView(mMicroAppBtn);
    mPopupWindow.setWidth(ListPopupWindow.MATCH_PARENT);
    mPopupWindow.setVerticalOffset(-60);
    mPopupWindow.setModal(true);

mMicroAppBtn is the big red button in the tab bar below.

On most devices ListPopupWindow is looking fine(not as above) in other words it is starting from the left of the screen not from it's center as above, which is what i want.

But on some devices it is showing like the image above, i tried several things but none worked for me.

Mohammad Haidar
  • 1,109
  • 1
  • 16
  • 35
  • check this https://stackoverflow.com/questions/6063667/show-a-popupwindow-centralized – hasan_shaikh May 15 '18 at 07:14
  • 1
    Am using ListPopupWindow no PopupWindow the solution in the link is not applicable, i mean there is no `showAtLocation()` method for ListPopupWindow – Mohammad Haidar May 15 '18 at 07:17
  • @MohammadHaidar Hi were you able to resolve the issue – MRamzan Jul 02 '20 at 09:33
  • @MRamzan i don't really remember but can you try adding mPopupWindow.setPromptPosition(ListPopupWindow.POSITION_PROMPT_ABOVE); and removing mPopupWindow.setVerticalOffset(-60); – Mohammad Haidar Jul 02 '20 at 12:42
  • I really appreciate your response. I do not know if it is a bug but setting verticle offset below -450 started working. After tweaking a little, at -350 I got the desired position for it. – MRamzan Jul 03 '20 at 06:16

0 Answers0