title: addView method does not display new view
body: <p>I want to add a new view to a <code>FrameLayout</code>, but it does only work "sometimes".
  For example: I have set an <code>OnClickListener</code> to my layout (inside the onCreate-method of the activity) which adds a new view to the layout (this works). In the run-method of the activity i am using exactly the same code to add such a view, but the view does not show up. I don't know why...</p>
  
  <p>Here is some code:</p>
  
  <p><code>OnClickListener</code>, which adds a new view to the layout and the view actually shows up. <code>layout</code> is the <code>FrameLayout</code>, <code>obstacles</code> is an object-list.</p>
  
  <pre><code>layout.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
          obstacles.add(new Obstacle(getBaseContext(), 0, (int) ((scale * 570) / 8), scale));
          layout.addView(obstacles.get(obstacles.size() - 1).view);
  
      }
  });
  </code></pre>
  
  <p>if statement IS true, the new view is not being displayed, but the size of obstacles and the layout's childcount increase both by 1</p>
  
  <pre><code>if(checkForNew()){
      obstacles.add(new Obstacle(getBaseContext(), 0, (int) ((scale * 570) / 8), scale));
      layout.addView(obstacles.get(obstacles.size() - 1).view);
  }
  </code></pre>
  
  <p>Constructor of <code>Obstacle</code></p>
  
  <pre><code>public Obstacle(Context con, int left, int top, float scale) {
      view = new ImageView(con);
      view.setBackgroundColor(Color.rgb(0, 0, 0));
      FrameLayout.LayoutParams params = new FrameLayout.LayoutParams((int)(scale*150), (int)(scale*20));
      params.setMargins(left,top,0,0);
      view.setLayoutParams(params);
      view.setMaxWidth(view.getLayoutParams().width);
      view.setMaxHeight(view.getLayoutParams().height);
  }
  </code></pre>
  
  <p>This is moving the views:</p>
  
  <pre><code>public void Move( View view, float speed, float scale){
      FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(view.getWidth(), view.getHeight());
      params.setMargins(view.getLeft(), view.getTop() - (int) (scale * -speed), 0, 0);
      view.setLayoutParams(params);
  }
  </code></pre>