I’m using a PopupWindow to show some subcategories when clicking on a ListView item.
I’m using the same layout for the ListView rows (categories) and for the PopupWindow (categories).
My problem is that I set the width of my PopupWindow to that of my row item view, but when it is displayed, it’s a bit narrower, with some kind of border.
On the screenshot below I put the PopupWindow on top of the ListView to se the difference
Why is it smaller? How can I remove this border?

listView.setOnItemClickListener(…)
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
showPopup(HomeActivity.this, layout_base, v, position);
}
}
});
showPopup(…)
public void showPopup(Context context, View parent, View view, int position){
/*
* Compute popup position and size
*/
int[] itemPosition = new int[2];
view.getLocationOnScreen(itemPosition);
int item_width = view.getWidth();
int item_height = view.getHeight();
int nChildren = GlobalVars.menuItemArray[position].children.size();
int popup_height = item_height * nChildren;
/*
* Build the view
*/
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout popupContainer = new LinearLayout(context);
popupContainer.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
popupContainer.setOrientation(LinearLayout.VERTICAL);
LayoutParams params;
params = new LayoutParams(item_width, item_height);
popupContainer.setOrientation(LinearLayout.VERTICAL);
for(int i=0; i<nChildren; i++){
RelativeLayout menu_row = (RelativeLayout) inflater.inflate(R.layout.menu_row, null);
popupContainer.addView(menu_row, params);
}
mPopup.setContentView(popupContainer);
mPopup.setHeight(popup_height);
mPopup.setWidth(item_width);
mPopup.showAtLocation(parent, Gravity.TOP|Gravity.LEFT, 0, 0);
}
I had to remove the background of the PopupWindow using: