当我点击我的按钮将新按钮添加到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);
}
答案 0 :(得分:4)
那是因为您使用FrameLayout
视图。尝试LinearLayout
垂直方向,一切都会好的。