ListPopupWindow not obeying WRAP_CONTENT width spec

前端 未结 9 1519
执念已碎
执念已碎 2021-02-02 07:12

I\'m trying to use ListPopupWindow to show a list of strings via an ArrayAdapter (eventually this will be a more complex custom adapter). Code is below. As shown in

9条回答
  •  一向
    一向 (楼主)
    2021-02-02 07:21

    You can actually get the anchorView's parent (since the actual anchorView is generally a button) and base your width from there. For example:

    popup.setWidth(((View)anchor.getParent()).getWidth()/2);
    

    That way you can get a flexible width.

提交回复
热议问题