如何以android上的代码(运行时)以编程方式更改我的按钮大小?
答案 0 :(得分:2)
button.setLayoutParams (new LayoutParams(20, LayoutParams.WRAP_CONTENT)
答案 1 :(得分:2)
使用以下代码
ViewGroup.LayoutParams params = myButton.getLayoutParams();
//Button new width
params.width = 400;
myButton.setLayoutParams(params);
答案 2 :(得分:1)
button.setLayoutParams(new LinearLayout.LayoutParams(YOUR WIDTH, YOUR HEIGHT));
答案 3 :(得分:0)
尝试使用LayoutParams
button.setLayoutParams (new LayoutParams(60, LayoutParams.WRAP_CONTENT))