2015-10-20 4 views

ответ

0

Вы можете установить местоположение всплывающего окна, а также его высоту и ширину.

Пройдите ниже кода:

int popupWidth = 200; 
    int popupHeight = 150; 


final PopupWindow popup = new PopupWindow(context); 
    popup.setContentView(layout); 
    popup.setWidth(popupWidth); 
    popup.setHeight(popupHeight); 
    popup.setFocusable(true); 

    // Some offset to align the popup a bit to the right, and a bit down, relative to button's position. 
    int OFFSET_X = 30; 
    int OFFSET_Y = 30; 

    // Clear the default translucent background 
    popup.setBackgroundDrawable(new BitmapDrawable()); 

    // Displaying the popup at the specified location, + offsets. 
    popup.showAtLocation(layout, Gravity.NO_GRAVITY, p.x + OFFSET_X, p.y + OFFSET_Y); 

Надеется, что это поможет. Приветствия!

Смежные вопросы