RelativeLayout - dynamically repositioning a view
<p>I am trying to do a simple task of moving a toolbar up and down on the screen, but it only works once. The toolbar moves on the press of a button to the top, but I cannot get it back to the bottom even though the message “move to bottom” appears. See the code:</p>

<pre><code>    boolean toolBarAtBottom = true;

    private void moveToolBar(){
        LinearLayout toolBar = (LinearLayout) findViewById(R.id.toolBar);
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                            LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

        lp.height = toolBar.getHeight();

        if (toolBarAtBottom){ 
            lp.addRule(RelativeLayout.ALIGN_TOP, RelativeLayout.TRUE);
        }else{  
            lp.addRule(RelativeLayout.ALIGN_BOTTOM, RelativeLayout.TRUE);
            Toast.makeText(DrawActivity.this, "move to bottom", Toast.LENGTH_SHORT).show();
        }
        toolBar.setLayoutParams(lp);
        toolBarAtBottom = !toolBarAtBottom;
    }
</code></pre>

<p>Any ideas how to make it do more than once?</p>
