Reputation: 7550
I've got a table with a couple of TextViews and two Buttons in each row. But the text in the buttons is much larger than the text in TextViews. How can I make the Buttons smaller?
Button view_button = new Button(this);
view_button.setText("test");
tr.addView(view_button);
Upvotes: 1
Views: 185
Reputation: 75
By using layout params you can set the height and width for button.
Button btnEdit = new Button(this);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
or
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(30,30);
btnEdit.setLayoutParams(layoutParams);
Upvotes: 0
Reputation: 157437
view_button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
Force it to wrap around the text
Upvotes: 1