【发布时间】:2012-01-19 09:49:56
【问题描述】:
我正在开发一个带有一些方形按钮的小型 Android 应用程序,这些按钮是从 Java 代码动态创建的。我正在使用 Absolute.LayoutParams 方法为它们提供宽度和高度,但我收到了弃用警告。
LayoutParams params = new LayoutParams(width,height, 0, 0);
button.setLayoutParams(params);
我也试过这个:
button.setHeight(height);
button.setWidth(width);
但它不起作用。还有第三种方法可以轻松清洁?
提前谢谢你!
【问题讨论】:
标签: android button height width