0
我正在Android Studio中使用ImageButton,並在代碼開發過程中需要更改ImageButton的維度。其他設置ImageButton維度的方法
我在上一個問題中遇到了解決方案的一部分。
stackoverflow.com/questions/10992241/set-imagebutton-height-and-width-in-code
android.view.ViewGroup.LayoutParams params1 = button1.getLayoutParams();
params1.height = size;
params1.width = size;
button1.setLayoutParams(params1);
android.view.ViewGroup.LayoutParams params2 = button2.getLayoutParams();
params2.height = size;
params2.width = size;
button2.setLayoutParams(params2);
android.view.ViewGroup.LayoutParams params3 = button3.getLayoutParams();
params3.height = size;
params3.width = size;
button3.setLayoutParams(params3);
是否有其他的方式來管理,而不重複後續的代碼全部ImageButtons?
android.view.ViewGroup.LayoutParams params1 = button1.getLayoutParams();
params1.height = size;
params1.width = size;