Reputation: 948
I've created a Button placed in a RelativeLayout and I'd like to set its size. But I can only set a larger size that the original one, for example I can resize it to 200dp but no to 20dp.
Is there a solution ?
Here is my code
Button b = new Button(getApplicationContext());
myLayout.addView(b);
b.setWidth(200); // Work
b.setWidth(20); // Don't work
Thanks
Upvotes: 3
Views: 4744
Reputation: 691
you can set the width of the button by giving values in the properties window of the design panel of the xml.on the right side of the UI design. You can use small button instead of button to make it a 20dpi.
Upvotes: 0
Reputation: 15728
That is because the Button
has a minimum width of 64dip
by default. Set it to 0
before setting the width.
b.setMinimumWidth(0);
Upvotes: 7