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
Buttonhas a minimum width of64dipby default. Set it to0before setting the width.