这个是popupwindow的内容xml(就是放了个ListView):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/ppw_settings_normal"
android:orientation="vertical" >
<ListView
android:id="@+id/lv_ppw_settings_lists"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:piderHeight="0dp"
android:listSelector="@android:color/transparent" >
</ListView>
</LinearLayout>
展现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了
然而结果却是:
醉了,这是什么缘故。。。
Because wrap_content is not effective for ListView, if there is no clear width height, it will be full by default.
. . Use popupMenu. . That’s the effect you want, and it’s much simpler and more beautiful than this one
Maybe it’s the layout problem of ListView’s items