I am creating a table row dynamically in android and creating a button in that row. All are rendering fine but the created button fills the parent, i.e. occupies the full width of the parent row. I want it as a fixed width array i.e. 150px.
My Code
TableRow rows = new TableRow(this);
TableLayout.LayoutParams tableRowParamss=
new TableLayout.LayoutParams
(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT);
rows.setBackgroundColor(Color.parseColor("#62b0ff"));
tableRowParamss.setMargins(0, 0, 0, 40);
rows.setLayoutParams(tableRowParamss);
Button ib = new Button(this);
//ib.setBackgroundResource(R.drawable.accept);
final float scale = getResources().getDisplayMetrics().density;
int heightDp = (int) (33 * scale + 0.5f);
int widthDp = (int) (60 * scale + 0.5f);
ViewGroup.LayoutParams bLp = new ViewGroup.LayoutParams(widthDp,heightDp);
rows.addView(ib);
table.addView(rows);
How can I make the button width fixed 150px and align to right side of row?