android-studio - android popupWindow 中宽度莫名很大,求帮助?
迷茫
迷茫 2017-04-17 15:33:42
0
3
529

这个是popupwindow的内容xml(就是放了个ListView):

  


展现popupwindow的时候,

public MenuPopup(final Context context) { **super(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);** View contentView = LayoutInflater.from(context).inflate(resId, null); ListView lv = (ListView) contentView .findViewById(R.id.lv_ppw_settings_lists); String[] menuItems = context.getResources().getStringArray(R.array.associator_query_menu); PopupSettingsAdapter adapter = new PopupSettingsAdapter(context, menuItems); .... }

我都用了wrap_content了
然而结果却是:

醉了,这是什么缘故。。。

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all (3)
左手右手慢动作

因为wrap_content对ListView是不起效的,没有明确的width hight,默认都是会撑满。

    伊谢尔伦

    。。用popupMenu吧。。那才是你想要的效果,并且比你这个简单美观多了

      阿神

      可能是ListView 的item的布局问题吧

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!