ListPopupWindow not obeying WRAP_CONTENT width spec

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

    I would just set a dimension in your dimen.xml file at 160dp or so:

    160dp
    

    Then set your popup width using the getDimensionPixelSize method to convert into pixels:

    int width = mContext.getResources().getDimensionPixelSize(R.dimen.overflow_width); 
    mListPopupWindow.setWidth(width);
    

    That should keep the size density independent.

提交回复
热议问题