在程序中我動態的創建了很多按鈕,但是如何在兩個按鈕之間添加空間呢?我用這樣的代碼
但是沒有實現,大家能幫助我嗎?謝謝!
private LinearLayout LLDynamic;
private RelativeLayout.LayoutParams ParaOne;
ParaOne = new RelativeLayout.LayoutParams(280, 30);
Button button1= new Button(Twindo_fromEditGroup.this);
button1.setTextSize(16);
LLDynamic = new LinearLayout(Twindo_fromEditGroup.this);
LLDynamic.setOrientation(LinearLayout.VERTICAL);
LLDynamic.addView(button1,ParaOne);
使用以下代碼添加空白:
Button button1 = new Button(this);
LinearLayout.LayoutParams rel_button1 = new LinearLayout.LayoutParams(buttonWidth, buttonHeight);
rel_button1.setMargins(20, 0, 0, 0);
button1.setLayoutParams(rel_button1);