我已经设置了一些 LinearLayout.LayoutParams
以仅使用 java 设置一些按钮。但我想将其从 WRAP_CONTENT
更改为我选择的高度和宽度。
//LinearLayout.LayoutParams top;
//this is declared at the top as it is used by different bits of the code.
top = new LinearLayout.LayoutParams
(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
top.topMargin = 100;
top.leftMargin = 120;
最佳答案
top = new LinearLayout.LayoutParams
(90, 80);
//随你喜欢
这是来自文档:
public LayoutParams(int width, int height) {
super(width, height);
weight = 0;
}
关于android - 使用 LinearLayout.LayoutParams 将 WRAP_CONTENT 更改为设定的数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39408567/