Change gravity of PopupWindow

后端 未结 2 422
感情败类
感情败类 2020-12-30 16:30

I have a button that must show a popup window. And the popup window must be aligned with the right side of the button. That\'s how I do it.

button.setOnClick         


        
相关标签:
2条回答
  • 2020-12-30 17:18

    The easiest way I've found is to specify the x-offset parameter:

    final View view = popup.getContentView();
    view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
    popup.showAsDropDown(button, button.getWidth() - view.getMeasuredWidth(), 0);
    
    0 讨论(0)
  • 2020-12-30 17:29

    You can try to change it from the xml file:

    android:layout_graviry="left"
    
    0 讨论(0)
提交回复
热议问题