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
That is because the Button has a minimum width of 64dip by default. Set it to 0 before setting the width.
b.setMinimumWidth(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With