Andreas
Andreas

Reputation: 7550

How to make a Button smaller?

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

Answers (2)

suman
suman

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

Blackbelt
Blackbelt

Reputation: 157437

view_button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

Force it to wrap around the text

Upvotes: 1

Related Questions