ListPopupWindow not obeying WRAP_CONTENT width spec

前端 未结 9 1555
执念已碎
执念已碎 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:29

    My approach to this.

    Create a Viewin your layout which functions as an anchor, with your dedicated width and position (Height 1 dp, width as you wish) (may be dynamic i.e. with ConstraintLayouts). Make it invisible (android:visibility=View.INIVISIBLE).

                    
    

    Reference to this view in your viewAnchor, (i.e with bindings):

    listPopupWindow.anchorView = binding.myAnchor

提交回复
热议问题