0
下面是我使用的显示弹出菜单的代码,以便它出现在我的列表视图Popmenu没有在列表视图行的中心对齐
lv.setOnItemLongClickListener(new OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
final int pos, long id) {
PopupMenu popup = new PopupMenu(context, arg1);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popup = new PopupMenu(context, arg1,Gravity.CENTER);
}
//Inflating the Popup using xml file
popup.getMenuInflater().inflate(R.menu.listmenu, popup.getMenu());
///some code
return true;
}
});
排的中心,但问题是popmenu总是出现在左侧。 当我给Gravity.RIGHT时,popmenu确实出现在行的最右侧。 中心显示出了什么问题?