1. 程式人生 > >PopupWindow7.0顯示在控制元件下面位置不對的問題

PopupWindow7.0顯示在控制元件下面位置不對的問題

if (Build.VERSION.SDK_INT != 24) {
    //只有24這個版本有問題,好像是原始碼的問題
mPopupWindow.showAsDropDown(select_dev_bg);
} else {
    //7.0 showAsDropDown沒卵子用 得這麼寫
int[] location = new int[2];
select_dev_bg.getLocationOnScreen(location);
    int x = location[0];
    int y = location[1];
mPopupWindow.showAtLocation(select_dev_bg
, Gravity.NO_GRAVITY, 0, y + select_dev_bg.getHeight()); }