title: Android Relative Layout on top other element
body: <p>I'm currently trying to make a data structure visualization app. The data structure I am trying to make is a stack. </p>
  
  <p>I am struggling to make an element on top of another once the user presses "Push". Below is the code that makes an element go to the bottom of the screen.</p>
  
  <p>I was wondering if are there any methods that could directly tells the next element to be aligned to the element that is already at the bottom now? </p>
  
  <pre><code>public void moveElem() {
  
      element1 = findViewById(R.id.element1);
  
      RelativeLayout.LayoutParams positionRules = new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      positionRules.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      positionRules.addRule(RelativeLayout.CENTER_HORIZONTAL);
      element1.setLayoutParams(positionRules);
  
      ViewGroup.LayoutParams sizeRules = element1.getLayoutParams();
      sizeRules.width = 400;
      sizeRules.height = 200;
      element1.setLayoutParams(sizeRules);
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/QHp35.png" alt=""></p>
  
  <p>Thank you all so much!</p>