I'm facing an issue setting margin to an inflated relative layout. Here is the code:
for(Produit prod : GlobalVariables.getInstance().getPanier())
{
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout layoutToInflate = (RelativeLayout)inflater.inflate(R.layout.cart_product_layout, null);
layoutToInflate.setTag(prod);
ManagedNetworkImageView prodPicture = (ManagedNetworkImageView) layoutToInflate.findViewById(R.id.productImage);
prodPicture.setImageUrl(prod.getImageDefaultUri(), GlobalVariables.getInstance().getImageLoader());
ImageView addBtn = (ImageView) layoutToInflate.findViewById(R.id.addBtn);
ImageView removeBtn = (ImageView) layoutToInflate.findViewById(R.id.removeBtn);
//Ajouter les actions sur les boutons de gestion de panier.
TextView productTitle = (TextView) layoutToInflate.findViewById(R.id.productTitle);
productTitle.setText(prod.getNom());
TextView productSpecs = (TextView) layoutToInflate.findViewById(R.id.productSpecs);
//Ajouter les spec choisi par l'utilisateur.
TextView productPrice = (TextView) layoutToInflate.findViewById(R.id.priceTextView);
productPrice.setText(Float.toString(prod.getPrixTtc()));
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
relativeParams.setMargins(0, 10, 0, 0); // left, top, right, bottom
layoutToInflate.setLayoutParams(relativeParams);
productInCartContainer.addView(layoutToInflate);
}
The goal is to inflate as much layouts as I have objects in my list, into a LinearLayout (productInCartContainer --> The parent view) with vertical orientation. All the layout have to be separated by a margin of 10.... I don't know what I'm doing wrong by there's no margin at all... I saw many post on that subject but nothing works... Does somebody sees what I'm doing wrong ?
Thanks in advance !