I have some problems trying to add a background image in my button programmatically. It works well on my XML file, but programmatically the background image of my button is bigger than normal. I mean my image is High:150px but when I run this code its looks bigger. I had already try setting my button maxheight function, but it doesn't works. BTW the button is inside a row, and the row (obviously) inside a TableLayout.
Thanks in advice for the help!
for(int i = 0; i < 3; i++){
TableRow tableRow = new TableRow(this);
tableRow.setId(0 + i);
tableRow.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 150));
Button btnProduct = new Button (this);
btnProduct.setId(10 + i);
btnProduct.setBackgroundResource(R.drawable.shoes1);
btnProduct.setHeight(150);
btnProduct.setWidth(161);
btnProduct.setText("View");
tableRow.addView(btnProduct);
mainTableLayout.addView(tableRow);
}