【问题标题】:When generating new views they are stacking on top of each other生成新视图时,它们相互堆叠
【发布时间】:2011-07-03 21:36:28
【问题描述】:

当我单击按钮以将新按钮添加到框架布局时,新按钮会堆叠在一起。知道我做错了什么吗?

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);
            }

【问题讨论】:

    标签: android layout view android-framelayout layoutparams


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-17
      • 2016-02-16
      • 1970-01-01
      • 1970-01-01
      • 2021-04-30
      • 1970-01-01
      相关资源
      最近更新 更多