2011-02-24 22 views
0

当我点击我的按钮来添加新的按钮到framelayout时,新的按钮堆叠在一起。任何想法我做错了什么?当生成新的视图时,它们堆叠在一起

public void onClick(View v) { 
       Button newAlarm = new Button(Hop_Timer.this); 
       newAlarm.setText(alarmMinutes.getText() + " Addition - Remove"); 
       newAlarm.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); 
       FrameLayout alarmsFrame = (FrameLayout) findViewById(R.id.display_alarms); 
       alarmsFrame.addView(newAlarm); 
      } 

回答

4

这是因为您使用了FrameLayout视图。尝试LinearLayout与垂直方向,一切都会好起来。

+0

这很好,非常感谢! – OFlan 2011-02-24 21:48:29